尝试与数据库同步后出现以下错误:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/vitaly/Documents/skillshare/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/vitaly/Documents/skillshare/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/vitaly/Documents/skillshare/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/vitaly/Documents/skillshare/local/lib/python2.7/site-packages/django/core/management/base.py", line 284, in execute
self.validate()
File "/home/vitaly/Documents/skillshare/local/lib/python2.7/site-packages/django/core/management/base.py", line 310, in validate
num_errors = get_validation_errors(s, app)
File "/home/vitaly/Documents/skillshare/local/lib/python2.7/site-packages/django/core/management/validation.py", line 34, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/home/vitaly/Documents/skillshare/local/lib/python2.7/site-packages/django/db/models/loading.py", line 196, in get_app_errors
self._populate()
File "/home/vitaly/Documents/skillshare/local/lib/python2.7/site-packages/django/db/models/loading.py", line 75, in _populate
self.load_app(app_name, True)
File "/home/vitaly/Documents/skillshare/local/lib/python2.7/site-packages/django/db/models/loading.py", line 99, in load_app
models = import_module('%s.models' % app_name)
File "/home/vitaly/Documents/skillshare/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/home/vitaly/Documents/skillshare/src/signups/models.py", line 6, in <module>
class SignUp(models.Model):
File "/home/vitaly/Documents/skillshare/src/signups/models.py", line 10, in SignUp
timestamp = models.DateTimeField(auto_now_add=True, auto_not=False)
File "/home/vitaly/Documents/skillshare/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 737, in __init__
Field.__init__(self, verbose_name, name, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'auto_not'
我是Django的新手,所以我真的不知道该怎么想。
答案 0 :(得分:2)
这是一个错字,而不是auto_not
,你可能意味着auto_now
。
替换
timestamp = models.DateTimeField(auto_now_add=True, auto_not=False)
使用:
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)