from django.db import models
class Post(models.Model):
title = models.CharField(max_length=100)
content = models.CharField(max_length=1000)
created = models.DateField()
modified = models.DateField()
python manage.py syncdb:
的错误Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 219, in execute
self.validate()
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/validation.py", line 35, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py", line 146, in get_app_errors
self._populate()
File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py", line 61, in _populate
self.load_app(app_name, True)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py", line 78, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/user1/djangoblog/../djangoblog/blog/models.py", line 7
created = models.DateField()
^
IndentationError: unexpected indent
答案 0 :(得分:5)
您是否在文件中混合了标签和空格?这是造成这种错误的最常见原因。
答案 1 :(得分:2)
我忍不住注意到您发布了使用标签的代码段。尝试使用空格缩进相同的代码。
答案 2 :(得分:1)
您可能有空格或制表符,其中需要有标签或空格。