google-code-export / django-values

Automatically exported from code.google.com/p/django-values
1 stars 1 forks source link

Circular import? #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I keep getting "ImportError: cannot import name Site" if I try to use sites
framework from any commandline script which imports models module, where I
have some module-level settings defined. The traceback looks like there is
some circular import of sites framework.

NB., importing this models module (or any of its models directly) from
within Django application works fine.

Original issue reported on code.google.com by jarek.zg...@gmail.com on 18 Apr 2008 at 1:21

GoogleCodeExporter commented 9 years ago
Actual traceback:

>>> from django.contrib.sites.models import Site
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/django/contrib/sites/models.py", line 9, in
<module>
    class Site(models.Model):
  File "/usr/lib/python2.5/site-packages/django/db/models/base.py", line 30, in __new__
    new_class.add_to_class('_meta', Options(attrs.pop('Meta', None)))
  File "/usr/lib/python2.5/site-packages/django/db/models/base.py", line 169, in
add_to_class
    value.contribute_to_class(cls, name)
  File "/usr/lib/python2.5/site-packages/django/db/models/options.py", line 53, in
contribute_to_class
    setattr(self, 'verbose_name_plural', meta_attrs.pop('verbose_name_plural',
self.verbose_name + 's'))
  File "/usr/lib/python2.5/site-packages/django/utils/functional.py", line 42, in
__wrapper__
    res = self.__func(*self.__args, **self.__kw)
  File "/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py",
line 268, in gettext
    _default = translation(settings.LANGUAGE_CODE)
  File "/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py",
line 197, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py",
line 182, in _fetch
    app = __import__(appname, {}, {}, [])
  File "/usr/lib/python2.5/site-packages/dbsettings/__init__.py", line 1, in <module>
    from dbsettings.values import *
  File "/usr/lib/python2.5/site-packages/dbsettings/values.py", line 5, in <module>
    from dbsettings.loading import get_setting_storage
  File "/usr/lib/python2.5/site-packages/dbsettings/loading.py", line 8, in <module>
    from dbsettings.models import Setting
  File "/usr/lib/python2.5/site-packages/dbsettings/models.py", line 2, in <module>
    from django.contrib.sites.models import Site
ImportError: cannot import name Site

Original comment by jarek.zg...@gmail.com on 30 Apr 2008 at 12:38

GoogleCodeExporter commented 9 years ago
Importing dbsettings before trying to import sites framework seems to be the 
quick
remedy, but I cann't recomment this as "solution to problem".

Original comment by jarek.zg...@gmail.com on 30 Apr 2008 at 12:47