输入此代码后,我会输入models.py
from django.db import models
from django.utils.encoding import smart_unicode
# Create your models here.
class SignUp(models.Model):
first_name = models.CharField(max_length = 120 , null = True , blank = True)
last_name = models.CharField(max_length = 120 , null = True , blank = True)
email = models.EmailField()
timestamp = models.DateTimeField(auto_now_add = True , auto_now = False)
updated = models.DateTimeField(auto_now_add = False , auto_now = True)
def __unicode__(self):
return smart_unicode(self.email) # return self.email
我在syncdb
时遇到此错误C:\Users\user\Desktop\project\src>python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
338, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
312, in execute
django.setup()
File "C:\Python27\lib\site-packages\django\__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python27\lib\site-packages\django\apps\registry.py", line 108, in pop
ulate
app_config.import_models(all_models)
File "C:\Python27\lib\site-packages\django\apps\config.py", line 198, in impor
t_models
self.models_module = import_module(models_module_name)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Users\Paramesh\Desktop\project\src\signup\models.py", line 11
updated = models.DateTimeField(auto_now_add = False , auto_now = True)
^
IndentationError: unindent does not match any outer indentation level
iam new django在此之前一切都没有错误
我没有得到什么是错误
我尝试删除它不起作用的时间戳
答案 0 :(得分:1)
您的线缩进中很可能会有与标签混合的空格。将IDE设置为显示空格和制表符,然后用空格替换制表符。
答案 1 :(得分:0)
时间戳之前有一个制表符。您应该使用空格或制表符来缩进Python,而不是两者。