python - django - circular import problem when executing a command -
I am developing a dynamic application. The modules for the importance of my problem are given below:
globals.py -> contains constants that are used throughout the application. SITE_NAME
and SITE_DOMAIN
are two of them and some are used to fill the string. Here's how I define them:
Import django.contrib.sites.models from the site ... SITE_DOMAIN = Site.objects.get_current (). Domain SITE_NAME = Site.objects.get_current () .name
models.py -> Models remain inside this module. Globals imports certain constants by
some_command.py -> A command that imports certain constants from global.
When executed, the order imports from globals.py and a circular import problem arise: globals.py , Sites app and Sites app are called import models.py in exchange with get_current () Strong> globals.py .
Edit:
Without facing the issue of this circular import, this application runs continuously at no charge. There is no problem importing globals.py from the shell even the command can be executed from the shell without calling manage.py .
So why does manage.py some_command fail due to a circular import?
Thanks in advance.
Is there any special reason for SITE_DOMAIN and globals.py in SITE_NAME? These sites are available directly from the framework. According to
, site object is cached when you access it for the first time, so importing it and using it does not hurt directly.
Comments
Post a Comment