Saturday, May 19, 2018

Re: whats the use of setting mysite.settings to DJANGO_SETTINGS_MODULE?

This is done so that when you run the script manage.py (that runs django commands) the module django imported by the script knows which project settings to use.

If you do not provide this, django will not recognize the apps you are developing, and will just recognize the default apps it comes bundled with.

https://docs.djangoproject.com/en/1.11/topics/settings/#envvar-DJANGO_SETTINGS_MODULE

On Thursday, May 17, 2018 at 12:09:33 AM UTC-3, Utpal Brahma wrote:
under manage.py


////


#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
    try:
        from django.core.management import execute_from_command_line
    except ImportError:
        # The above import may fail for some other reason. Ensure that the
        # issue is really that Django is missing to avoid masking other
        # exceptions on Python 2.
        try:
            import django
        except ImportError:
            raise ImportError(
                "Couldn't import Django. Are you sure it's installed and "
                "available on your PYTHONPATH environment variable? Did you "
                "forget to activate a virtual environment?"
            )
        raise
    execute_from_command_line(sys.argv)



--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/fe7f1f18-69d5-49e8-ac67-593e6914fa63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment