从repo中删除.pyc文件时出现Django错误

时间:2012-07-23 22:54:42

标签: django git

我几个小时以来一直在摸不着头脑。

我一直很高兴地在测试服务器上拉我回购。该项目有很多提交。我想清理我的repo中的所有.pyc文件,所以在我的主人中删除它们并将* .pyc添加到.gitignore。这是对最后一次提交的唯一更改。

现在,当我拉到测试服务器时,Django导入失败。然而,该模块在那里,除了.pyc expunging之外没有其他变化。所以这个错误基本上是假的。

如果我重新添加.pyc文件,它会再次愉快地工作。

任何人都可以对此有所了解吗?

编辑:

这是追溯:

Traceback (most recent call last):
File "./manage.py", line 14, in <module>
  execute_manager(settings)
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
  utility.execute()
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
  self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
  self.execute(*args, **options.__dict__)
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/core/management/base.py", line 209, in execute
  translation.activate('en-us')
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 100, in activate
  return _trans.activate(language)
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 202, in activate
  _active.value = translation(language)
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 185, in translation
  default_translation = _fetch(settings.LANGUAGE_CODE)
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 162, in _fetch
  app = import_module(appname)
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
  __import__(name)
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 3, in <module>
  from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/contrib/admin/helpers.py", line 3, in <module>
  from django.contrib.admin.util import (flatten_fieldsets, lookup_field,
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/contrib/admin/util.py", line 1, in <module>
  from django.db import models
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/db/__init__.py", line 67, in <module>
  router = ConnectionRouter(settings.DATABASE_ROUTERS)
File "/home/galadarwin/.virtualenvs/datazone/lib/python2.7/site-packages/django/db/utils.py", line 114, in __init__
  raise ImproperlyConfigured('Error importing database router %s: "%s"' % (klass_name, e))
django.core.exceptions.ImproperlyConfigured: Error importing database router JournalRouter: "No module named journal.routers"

2 个答案:

答案 0 :(得分:1)

事实证明__init__.py已将其作为.gitignore中的参数。所以我的所有模块都是在没有__init__.py的情况下提交的。虽然__init__.pyc文件仍然存在,但这些文件必须被用作'后备'(我没有意识到python会这样做)所以我的错误被混淆了。我很糟糕,但我学到了很多好的教训。

答案 1 :(得分:0)

要清理Django .pyc文件,请执行终端中的一个或所有命令:

import formly from 'angularFormly';
import formlyBootstrap from 'formlyAngularTemplatesBootstrap';

export const FormlyUtilityModule = angular
  .module('formly-utility', [
     formly,
     formlyBootstrap
  ])
  .name;