我开始学习Django并且一直关注Django网站上的在线教程。
一切都工作正常,我有一个名为mysite的文件夹,然后是子文件夹,名为mysite /和manage.py,就像在教程中所说:https://docs.djangoproject.com/en/1.5/intro/tutorial01/#creating-a-project
然而,当我运行命令
时$ python manage.py runserver
我明白了:
Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x10165aed0>>
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/django/core/management/commands/runserver.py", line 92, in inner_run
self.validate(display_num_errors=True)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 280, in validate
num_errors = get_validation_errors(s, app)
File "/Library/Python/2.6/site-packages/django/core/management/validation.py", line 35, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/Library/Python/2.6/site-packages/django/db/models/loading.py", line 166, in get_app_errors
self._populate()
File "/Library/Python/2.6/site-packages/django/db/models/loading.py", line 72, in _populate
self.load_app(app_name, True)
File "/Library/Python/2.6/site-packages/django/db/models/loading.py", line 96, in load_app
models = import_module('.models', app_name)
File "/Library/Python/2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Python/2.6/site-packages/django/contrib/auth/models.py", line 21, in <module>
from django.contrib.contenttypes.models import ContentType
File "/Library/Python/2.6/site-packages/django/contrib/contenttypes/models.py", line 127, in <module>
class ContentType(models.Model):
File "/Library/Python/2.6/site-packages/django/db/models/base.py", line 97, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
TypeError: Error when calling the metaclass bases
__init__() keywords must be strings
根据教程,它应该说:
Validating models...
0 errors found
April 14, 2013 - 15:50:53
Django version 1.5, using settings 'mysite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
我试图在我的网络浏览器中转到http://127.0.0.1:8000/
,但我只是错误连接。
有人知道我出错的地方或我需要做些什么来纠正这个问题吗?
我正在使用Django 1.5和Python 2.6.1。
答案 0 :(得分:4)
根据Django docs:
Django 1.5适用于从2.6.5到2.7的任何Python版本。
根据this ticket,我建议你升级你的Python版本。或者,如果您无法升级它,您可以采用另一种方式,该方式显示在故障单的last comment中:
使用支持Python 2.5 +的Django 1.4