dajaxice DajaxiceFinder失败了collectstatic

时间:2013-10-30 06:26:06

标签: python django dajaxice

我在一个django项目中安装了dajaxice。当我使用manage.py runserver运行网络时,一切顺利。现在我尝试使用apache / wsgi进行部署。当我运行manage.py collectstatic时,会发生错误:

ImportError: cannot import name Bag

其中Bag是我的应用程序中的一个模型。

我试过

manage.py shell

然后导入Bag,我运作良好。

我尝试从settings.py中注释掉DajaxiceFinder,正常收集了collectstatic。

有人可以帮助我吗?

由于


ImportError的完整堆栈:

  Traceback (most recent call last):
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 222, in run_from_argv
      self.execute(*args, **options.__dict__)
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 255, in execute
      output = self.handle(*args, **options)
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 385, in handle
      return self.handle_noargs(**options)
    File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 164, in handle_noargs
      collected = self.collect()
    File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 114, in collect
      handler(path, prefixed_path, storage)
    File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 285, in copy_file
      if not self.delete_file(path, prefixed_path, source_storage):
    File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 224, in delete_file
      source_last_modified = source_storage.modified_time(path)
    File "/usr/local/lib/python2.7/dist-packages/django/core/files/storage.py", line 277, in modified_time
      return datetime.fromtimestamp(os.path.getmtime(self.path(name)))
    File "/usr/local/lib/python2.7/dist-packages/dajaxice/finders.py", line 55, in path
      path = self.get_or_create_file(name)
    File "/usr/local/lib/python2.7/dist-packages/dajaxice/finders.py", line 21, in get_or_create_file
      data = getattr(self, self.files[path])()
    File "/usr/local/lib/python2.7/dist-packages/dajaxice/finders.py", line 68, in dajaxice_core_js
      dajaxice_autodiscover()
    File "/usr/local/lib/python2.7/dist-packages/dajaxice/core/Dajaxice.py", line 135, in dajaxice_autodiscover
      import_module("%s.ajax" % app)
    File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
      __import__(name)
    File "/home/emini/project/emini/trunk/emini/repairment/ajax.py", line 4, in <module>
      from emini.repairment.models import Bag
    File "/home/emini/project/emini/trunk/emini/repairment/models.py", line 9, in <module>
      class Bag(models.Model):
    File "/home/emini/project/emini/trunk/emini/repairment/models.py", line 90, in Bag
      shop_id                 = models.IntegerField(default=0, db_index=True, choices=DataConfig.get_valid_conf_as_choices_by_group(DataConfig.GROUP_NAME_SHOP), verbose_name="店铺")
    File "/home/emini/project/emini/trunk/emini/sysconfig/models.py", line 62, in get_valid_conf_as_choices_by_group
      data_configs = cls.objects.filter(group_name=group_name, enabled=True).order_by('-id')
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 155, in filter
      return self.get_query_set().filter(*args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 669, in filter
      return self._filter_or_exclude(False, *args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 687, in _filter_or_exclude
      clone.query.add_q(Q(*args, **kwargs))
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 1271, in add_q
      can_reuse=used_aliases, force_having=force_having)
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 1139, in add_filter
      process_extras=process_extras)
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 1325, in setup_joins
      field, model, direct, m2m = opts.get_field_by_name(name)
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 351, in get_field_by_name
      cache = self.init_name_map()
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 380, in init_name_map
      for f, model in self.get_all_related_m2m_objects_with_model():
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 469, in get_all_related_m2m_objects_with_model
      cache = self._fill_related_many_to_many_cache()
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 483, in _fill_related_many_to_many_cache
      for klass in get_models(only_installed=False):
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 197, in get_models
      self._populate()
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 75, in _populate
      self.load_app(app_name)
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 96, in load_app
      models = import_module('.models', app_name)
    File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
      __import__(name)
    File "/home/emini/project/emini/trunk/emini/express/models.py", line 6, in <module>
      from emini.repairment.models import Bag
  ImportError: cannot import name Bag

环境:

Django==1.5.4
django-dajaxice==0.5.5

我尝试从express / models.py中删除导入包,然后从collectstatic中删除。

我的应用的结构:

    emini
        express
            models.py
        repairment
            models.py

在emini.express.models中:

from emini.repairment.models import Bag


class Package(models.Model):
    foo = models.CharField(max_length=20)


class BagPackageLink(models.Model):
    bag = models.ForeignKey(Bag)
    package = models.ForeignKey(Package)

    class Meta:
        unique_together = (("bag", "package"),)

in emini.repairment.models

class Bag(models.Model):
    foo = models.CharField(max_length=20)

我是否搞砸了'重叠导入'? 但是为什么runserver和shell可以导入Bag模型?

0 个答案:

没有答案