属性错误:模块'django.db.models'没有属性'BigAutoField'



所以我是按照《Python速成班第二版》教材中的Django项目学习的。我进入映射url部分为那些知道,当我尝试我的系统似乎不能运行服务器了,我遇到以下错误:AttributeError: module 'django.db。models'没有属性'BigAutoField'

如果有人能帮忙,那就太好了,谢谢。我是相当新的django和尝试我的方式围绕它,但我真的不知道什么或在哪里找到错误..

在我添加两个url .py:

之前,它工作得很好
from django.urls import path, include
from django.contrib import admin
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('learning_logs.urls'), name='learning_logs'),
]

"""Defines url patterns for learning_logs."""
from django.urls import path
from . import views
app_name = 'learning_logs'
urlpatterns = [
# Home page.
path('', views.index, name='index'),
]

models.py是

from django.db import models
# Create your models here.
class Topic(models.Model):
"""A topic the user is learning about"""
text = models.CharField(max_length=200) 
date_added = models.DateTimeField(auto_now_add=True) 
def __str__(self):
"""return a string representation of the model"""
return self.text 

class Entry(models.Model):
"""something specific learned about a topic"""
topic = models.ForeignKey(Topic, on_delete=models.CASCADE)
text = models.TextField()
date_added = models.DateTimeField(auto_now_add=True)
class Meta: 
verbose_name_plural = 'entries'
def __str__(self):  
"""return a string representation of the model"""
if len(self.text) >= 50:
return f"{self.text[:50]}..."
else:
return "..."

这是您必须更改的版本。Django 1.8没有BigAutoField
这是Django 1.8 doc的url

最新更新