dajaxice DajaxiceFinder失败collectstati

2024-03-28 16:18:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我在django项目中安装了dajaxice。当我使用manage.py runserver运行web时,一切都很顺利。现在我尝试用apache/wsgi来部署它。当我运行manage.py collectstatic时,出现错误:

ImportError: cannot import name Bag

包是我应用程序中的一个模型。在

我试过了

^{2}$

然后进口包,我工作得很好。在

我试着从设置.py,collectstatic正常完成。在

有人能帮我吗?在

谢谢


一大堆重要的事情:

  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

我试着从快递里删除进口包/模型.py,然后collectstatic成功。在

我的应用程序结构:

    emini
        express
            models.py
        repairment
            models.py

在emini.express.型号公司名称:

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"),)

在艾米尼.修理.模型在

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

我是不是搞砸了“重叠导入”? 但是为什么runserver和shell可以导入Bag模型呢?在


Tags: djangonameinpyselfdbmodelslib