I am trying to upgrade a project from Django 1.6 to 1.7. I get the following error:
[Thu Oct 09 14:16:41 2014] [error] [client 95.79.172.156] mod_wsgi (pid=1
see http://django.readthedocs.org/en/latest/releases/1.7.html#standalone-scripts
import django
django.setup()
For those (like me) who are getting this error from shell:
Check that you are executing Django's shell and not Python's shell.
python manage.py shell
In configuration uwsgi application file ( like uwsgi.ini ) replace:
module = django.core.handlers.wsgi:WSGIHandler()
on
module=django.core.wsgi:get_wsgi_application()
settings.AUTH_USER_MODEL
is a string (that's why you get AttributeError: 'str' object has no attribute '_meta'
- it expects a Model) and should be used only on ForeignKey
declarations:
class Article(models.Model): author = models.ForeignKey(settings.AUTH_USER_MODEL)
If you want to refer to your user model somewhere else you need to use get_user_model
:
from django.contrib.auth import get_user_model UserModel = get_user_model()
In my case the error was caused when I upgraded celery to 4.x and I had this in my INSTALLED_APPS: kombu.transport.django
. Removing that resolved the issue. Seems it is mostly caused by some incorrect load of django itself.
I got this error when moving to a different PC and forgetting to install psycopg2
in my venv and when using 'ENGINE': 'django.db.backends.postgresql',
in my settings.
Perhaps it can be useful to someone else.