Django:runserver无法运行

时间:2013-05-11 17:25:42

标签: python django

我已按照DjangoProject教程安装并创建了一个项目。 一切正常,我通过在Python命令行输入import django来检查是否安装了Django。

但是,当我键入python manager.py runserver时,它将无法正常工作。我没有编辑任何文件,一步一步地按照教程,所以我真的没有看到什么是错的。

这是我得到的错误:

Unhandled exception in thread started by <bound method Command.inner_run of    <    django.contrib.staticfiles.management.commands.runserver.Command object at 0x101115fd0>>
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

提前致谢!

1 个答案:

答案 0 :(得分:6)

我怀疑你使用的是早于2.6.5的Python版本,以及最新的Django版本。 Django 1.5仅与Python 2.6.5+兼容。您应该升级Python,或使用Django 1.4。