我从Mac OS X 10.7上的端口安装了Django 1.4.1和Python 2.7。当我尝试运行manage.py runserver 8000时,我收到一个错误:
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x10bb840d0>>
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 91, in inner_run
self.validate(display_num_errors=True)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/Library/Python/2.7/site-packages/django/core/management/validation.py", line 30, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 158, in get_app_errors
self._populate()
File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 64, in _populate
self.load_app(app_name, True)
File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 88, in load_app
models = import_module('.models', app_name)
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Users/rankor777/PycharmProjects/PyCart/PyCartApp/models.py", line 40, in <module>
class Photo(models.Model):
File "/Users/rankor777/PycharmProjects/PyCart/PyCartApp/models.py", line 41, in Photo
title = models.Model(max_length=128)
File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 289, in __init__
if args_len > len(self._meta.fields):
AttributeError: 'Model' object has no attribute '_meta'
这是什么,以及如何解决它?
答案 0 :(得分:1)
我不知道为什么你认为这与MacPorts有关。回溯显示错误,该错误位于PyCartApp/models.py
的第41行:您已将models.Model(max_length=128)
放在我认为您打算放置models.CharField(max_length=128)
的位置。