Post by Gear Crewwhen i can use it in any project?
Have a look at wsgi.py created by django-admin when you start a new
project. That should let you understand how to use Django in multiple
projects. In my case, I use different virtualenvs and separate
installations of Django in development. In production I have a single
environment with two running projects ie two Django websites in separate
virtual hosts each with their environment variables managed by Apache.
I'm not sure it is the best way to do it but I haven't encountered any
problems yet.
Here is an example of one of my wsgi.py files ...
from __future__ import unicode_literals, absolute_import, division
import os
import sys
from socket import gethostname
from django.core.wsgi import get_wsgi_application
project = "xxxx"
srvroot = "/var/www"
site_root = "%s/%s" % (srvroot, project)
hname = gethostname()
if "pq4" in hname:
site = "production"
elif "pq3" in hname:
site = "staging"
else:
site = "dev"
if site_root not in sys.path:
sys.path.insert(0, site_root)
os.environ["DJANGO_SETTINGS_MODULE"] = "%s.settings.%s" % (project, site)
os.environ["PYTHON_EGG_CACHE"] = site_root
# this is the public API - returns django.core.handlers.wsgi.WSGIHandler()
application = get_wsgi_application()
Post by Gear CrewPost by Gear CrewI want to understand why do that
Because Django needs to know which settings module to use so it can find
all your apps and models.
It was designed that way so that a single installation of Django could
be used for multiple projects.
Post by Gear CrewScreenshot from 2018-11-11 18-09-56.png
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from
it, send
<javascript:>
Post by Gear CrewVisit this group at https://groups.google.com/group/django-users
<https://groups.google.com/group/django-users>.
Post by Gear CrewTo view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/082717ec-8e88-445d-a0c1-2032f2de9144%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/082717ec-8e88-445d-a0c1-2032f2de9144%40googlegroups.com>
<https://groups.google.com/d/msgid/django-users/082717ec-8e88-445d-a0c1-2032f2de9144%40googlegroups.com?utm_medium=email&utm_source=footer
<https://groups.google.com/d/msgid/django-users/082717ec-8e88-445d-a0c1-2032f2de9144%40googlegroups.com?utm_medium=email&utm_source=footer>>.
Post by Gear CrewFor more options, visit https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/50608575-2738-4f89-bcb1-5ee55c8d062a%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/50608575-2738-4f89-bcb1-5ee55c8d062a%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5922fe86-0362-e33f-10a3-9565946ebaf4%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.