所以我在网上做这个教程“https://www.youtube.com/watch?v=KqN4u28T-JQ”,我收到了这个错误。我尽我所能找出我做错了什么,我很难过。
我的admin.py文件
from django.contrib import admin
# Register your models here.
from blog.models import Post
admin.site.register(Post)
我的models.py文件
models.py
from django.db import models
# Create your models here.
class Post(models.Model):
title = models.CharField(max_length = 140)
body = models.TextField()
date = models.DateTimeFeild()
def __unicode__(self):
return self.title
将manage.py syncdb放入控制台时返回的内容。
C:\Users\user\Desktop\mysite\mysite>manage.py syncdb
Traceback (most recent call last):
File "C:\Users\user\Desktop\mysite\mysite\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django-1.8.3-py2.7.egg\django\core\managem
ent\__init__.py", line 338, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django-1.8.3-py2.7.egg\django\core\managem
ent\__init__.py", line 312, in execute
django.setup()
File "C:\Python27\lib\site-packages\django-1.8.3-py2.7.egg\django\__init__.py"
, line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python27\lib\site-packages\django-1.8.3-py2.7.egg\django\apps\registr
y.py", line 108, in populate
app_config.import_models(all_models)
File "C:\Python27\lib\site-packages\django-1.8.3-py2.7.egg\django\apps\config.
py", line 198, in import_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\user\Desktop\mysite\mysite\blog\models.py", line 4, in <modul
e>
class Post(models.Model):
File "C:\Users\user\Desktop\mysite\mysite\blog\models.py", line 7, in Post
date = models.DateTimeFeild()
AttributeError: 'module' object has no attribute 'DateTimeFeild'
答案 0 :(得分:0)
看起来你有一个错字:s / Feild / Field / g
答案 1 :(得分:0)
也许你可以试试这个:
date = models.DateFeild()
答案 2 :(得分:0)
尝试使用DateTimeField而不是DateTimeFeild