66π
If you are using your django project applications in standalone scripts, in other words, without using manage.py
β you need to manually call django.setup()
first β it would configure the logging and, what is important β populate apps registry.
Quote from Initialization process docs:
setup()
This function is called automatically:
When running an HTTP server via Djangoβs WSGI support.
When invoking a
management command.It must be called explicitly in other cases, for
instance in plain Python scripts.
In your case, you need to call setup()
manually:
if __name__ == '__main__':
print "Starting Rango population script..."
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tangle.settings')
import django
django.setup()
populate()
Also, this problem is described in detail in Troubleshooting section.
3π
I found this solution, adding
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
after
os.environ.setdefault ...
- [Django]-Limit number of characters with Django Template filter
- [Django]-How do I remove Label text in Django generated form?
- [Django]-MySQL vs PostgreSQL? Which should I choose for my Django project?
3π
I just stumbled about the same problem in my local development server.
After pulling some changed code in, the error was thrown.
The problem here obviously has nothing to do with wsgi, so I tried to run manage.py
A simple: python manage.py
reveals the real error cause.
In my case a forgotten import of an external Django app.
Maybe this helps someone else out.
- [Django]-Django rest framework change primary key to use a unqiue field
- [Django]-'staticfiles' is not a valid tag library: Template library staticfiles not found
- [Django]-Django and domain driven design
1π
I also encountered this problem using Django 1.7 on an Apache server. Changing the wsgi
handler call in my wsgi.py
file fixed the problem:
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
This was suggested here by user βjezdezβ.
- [Django]-What the difference between using Django redirect and HttpResponseRedirect?
- [Django]-Is it possible to decorate include(β¦) in django urls with login_required?
- [Django]-What is the SQL ''LIKE" equivalent on Django ORM queries?