我遇到了一个我不知道如何解决的奇怪错误。我最近将我的Ubuntu升级到14.04(显然也升级了我的Python),当我在urls.py文件中取消注释 admin.autodiscover()方法时,Django开始抛出TypeError。当我评论它,该网站工作正常,但是,我失去了管理员访问权限,从管理界面编辑任何东西。回溯和要求如下。谢谢!
File "/home/bram/.virtualenvs/viso_project/local/lib/python2.7/site- packages/django/core/handlers/base.py" in get_response
99. resolver_match = resolver.resolve(request.path_info)
File "/home/bram/.virtualenvs/viso_project/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
337. for pattern in self.url_patterns:
File "/home/bram/.virtualenvs/viso_project/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in url_patterns
365. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/bram/.virtualenvs/viso_project/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in urlconf_module
360. self._urlconf_module = import_module(self.urlconf_name)
File "/home/bram/.virtualenvs/viso_project/local/lib/python2.7/site-packages/django/utils/importlib.py" in import_module
40. __import__(name)
File "/home/bram/Code/Dropbox/viso_project/viso_project/urls.py" in <module>
7. admin.autodiscover()
File "/home/bram/.virtualenvs/viso_project/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py" in autodiscover
29. import_module('%s.admin' % app)
File "/home/bram/.virtualenvs/viso_project/local/lib/python2.7/site-packages/django/utils/importlib.py" in import_module
40. __import__(name)
File "/home/bram/Code/Dropbox/viso_project/sa_programs/admin.py" in <module>
55. admin.site.register(UserProfile, UserProfileAdmin)
File "/home/bram/.virtualenvs/viso_project/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in register
92. admin_class.validate(model)
File "/home/bram/.virtualenvs/viso_project/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in validate
106. validator.validate(cls, model)
File "/home/bram/.virtualenvs/viso_project/local/lib/python2.7/site-packages/django/contrib/admin/validation.py" in validate
25. getattr(self, m)(cls, model)
File "/home/bram/.virtualenvs/viso_project/local/lib/python2.7/site-packages/django/contrib/admin/validation.py" in validate_inlines
224. if not issubclass(inline.model, models.Model):
Django==1.6.5
Fabric==1.9.0
South==1.0
argparse==1.2.1
distribute==0.6.24
django-appconf==0.6
django-bootstrap-form==3.1
django-crispy-forms==1.4.0
django-forms-bootstrap==3.0.0
django-user-accounts==1.0c9
ecdsa==0.11
paramiko==1.14.0
pinax-theme-bootstrap==5.4.0
pinax-theme-bootstrap-account==1.0b2
pycrypto==2.6.1
pytz==2014.4
six==1.7.3
wsgiref==0.1.2
异常类型:/ admin /
的TypeError 异常值:issubclass()arg 1必须是类
答案 0 :(得分:1)
在您看到Ubuntu升级后(可能从12.04到14.04),python版本有所不同。这意味着您尝试使用旧环境的虚拟环境已损坏。您需要重新创建所有虚拟环境,因为即使在标准的python库中也可能发生一些奇怪的冲突。
编辑:
如果您使用virtualenvwrapper,则可以输入:
rmvirtualenv <envname>
mkvirtualenv <envname> -r <path/to/requirement.txt>
这将使用requirements.txt
文件中列出的软件包再次删除并创建环境。
注意:如果您处于活动环境中,请先删除它,然后再删除虚拟环境。