所以我在線做這個教程「https://www.youtube.com/watch?v=KqN4u28T-JQ」,我得到這個錯誤。我盡力找出我做錯了什麼,我很難過。attributeError:「模塊」對象沒有任何屬性「DateTimeField」
我的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'
你能解釋一下你想做什麼嗎? – Cleb
請注意錯誤。你有一個錯字:'DateTimeFeild'。 –
UHGHGHGHGH尷尬DateTimeFeild錯字 –