I want to remove the django.contrib.comments app from a project I'm working on. I tried:
$ python manage.py sqlclear django.contrib.comments
on the shell but got:
Error: App with label django.contrib.comments could not be found. Are
you sure your INSTALLED_APPS setting is correct?
I have double checked my INSTALLED_APPS setting and indeed django.contrib.comments is present.
Any suggestions on how to get around this?
The app_name is actually just the last element of the file path. So comments should work.
You could run
python manage.py reset app_name
Then remove app_name from your installed apps.
Related
When I try to run my server in Django it is not able to find my app track that I just created:
ModuleNotFoundError: No module named 'track'
I got the same message for the app I was working on previously. I also get error messages relating to bootstrap, the last one being this:
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'
I started noticing this once I removed the bootstrap configurations from another app I was working on. I just downloaded bootstrap and know very little about it, especially how it could stop a Django server from running and not recognizing my app.
Any ideas???
If you already created an app which is 'track' by this command: python manage.py startapp track, don't forget to add it to the installed apps on the settings.py.
example:
INSTALLED_APPS = [
'app1',
'track',
'app2'
]
Also don't forget the add "," after each app, last one doesn't matter.
How to run Django-simple-blog? I tried to install django-simple-blog but could not find the manage.py file to run it. Can I get a solution or another simple blog?
Django has a concept of apps and a concept of projects. A project will have a manage.py file like you mention, and will also have a settings.py file that declares all of the apps that the project uses.
django-simple-blog is an app, meaning you install it within an existing project. After this explaination, the rest of the steps found here should be easier to follow: https://github.com/drager/django-simple-blog/blob/master/README.rst
The remaining steps are to:
Add 'simpleblog' to INSTALLED_APPS in your settings.py file
run the command python manage.py migrate from your project root
include 'simpleblog.urls' into any of your urls.py file
I have Django 1.9 app that runs with python 3.5.1.
First when I run "manage.py runserver" I think it fail because I dont have "psycopg2",he crushes because he couldn't find "psycopg2",
I installed it with pip install, and now there is no error, the "runserver" command works well and give me only that:
$ /c/Python35/python.exe manage.py runserver
C:\django-master\project\urls.py:12: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead.
url(r'^rank2/$', views.rank2, name='rank2'),)
C:\django-master\website\urls.py:21: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead.
url(r'^project/', include('project.urls')),
It looks like he is running but when I entered 127.0.0.1 there is nothing, its probably not really work, but I dont know how to debug it because there are no errors, how can I know where the problem is? (I know it could be lot of things but I don't have any direction...)
Thanks...
Django is per default running on port 8000 not port 80. Either you go to 127.0.0.1:8000 or you start the server with /c/Python35/python.exe manage.py runserver 80
I got a basic Django setup working on my webhost, then I copied it down to my local machine. Both my local and my remote are using the same version of Django, and the same database (Postgres) with the same exact settings.py.
The thing is, when I run manage.py runserver on my local, and then browse to localhost, I get:
ViewDoesNotExist at /
Could not import myapp.main. View is not callable.
The view does exist though, and works perfectly fine on my remote. When I look at the PYTHONPATH in the debug output it includes the base directory of my django setup, and the "main" app is in the INSTALLED_APPS in my settings.py.
Basically everything is setup the same as on my remote (except that the remote is using Apache and I'm using runserver), at least as far as I can tell, but they are behaving differently. Does anyone have any clue what could be wrong?
EDIT:
It turns out I'm an idiot, and one of my files (urls.py) on the server never made it in to the commit. As a result, my local file wasn't what I thought it was, and I failed to realize the problem. Once I updated urls.py everything worked.
put 'myapp' in your settings.py
INSTALLED_APPS = (
'myapp',
)
urls.py
url(r'^$', 'myapp.views.main', name='main'),
check that in views.py, a function named 'main' should be there
I'm trying to get South to work - it worked fine on my PC, but I'm struggling to deploy it on my webhost.
Right now it seems that any changes I make to add/remove items from INSTALLED_APPS aren't being picked up by syncdb or diffsettings. I've added south to my list of INSTALLED_APPS, but the tables it needs aren't being created when I run syncdb. If I change other settings, they are picked up, it just seems to be INSTALLED_APPS that doesn't work.
If I run
from south.db import db
from the shell I get with manage.py shell, I don't get any import errors, so I don't think it's a problem with where south is. I've tried removing all my other applications (other than the Django standard ones), and tables for them still get created when I run syncdb.
Even if I delete INSTALLED_APPS completely, I still get the old list of INSTALLED_APPS when I run manage.py diffsettings.
Any ideas what I've done wrong?
Thanks,
Dom
If you write a migration for an application, syncdb wont work.
You have to use
manage.py migrate
syncdb wont work for applications which are hooked under migration using south. Those applications model change will be noticed only depending on south migration history.
South Migration Docs
The answer, it turns out, is that I'm a moron. I'd done this:
In settings.py:
...
INSTALLED_APPS = (
...
)
...
from localsettings import *
In localsettings.py
...
INSTALLED_APPS = (
...
)
...
I'd created localsettings.py from settings.py, to contain things only relevant to the current location of the project (like database settings), and forgot to delete the INSTALLED_APPS section.
Apologies for doing such a flagrantly stupid thing.