Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 属性错误:';模块';对象没有属性';日期字段';_Python_Django - Fatal编程技术网

Python 属性错误:';模块';对象没有属性';日期字段';

Python 属性错误:';模块';对象没有属性';日期字段';,python,django,Python,Django,在models.py文件中 from django.db import models # Create your models here. class Publisher(models.Model): name = models.CharField(max_length=30) address = models.CharField(max_length=50) city = models.CharField(max_length=60) state_provi

在models.py文件中

from django.db import models

# Create your models here.

class Publisher(models.Model):
    name = models.CharField(max_length=30)
    address = models.CharField(max_length=50)
    city = models.CharField(max_length=60)
    state_province = models.CharField(max_length=30)
    country = models.CharField(max_length=50)
    website = models.URLField()

class Author(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=40)
    email = models.EmailField()

class Books(models.Model):
    title = models.CharField(max_length=100)
    authors = models.ManyToManyField(Author)
    publishers = models.ForeignKey(Publisher)
    publication_date = models.Datefield()
当我运行命令时

$ python manage.py validate
我收到了错误信息

AttributeError: 'module' object has no attribute 'Datefield'
请帮忙。

应该用大写字母
F

因此,您的
书籍
模型应如下所示:

class Books(models.Model):
    title = models.CharField(max_length=100)
    authors = models.ManyToManyField(Author)
    publishers = models.ForeignKey(Publisher)
    publication_date = models.DateField()  # <--- Typo was here
教材(models.Model):
title=models.CharField(最大长度=100)
作者=模型。ManyToManyField(作者)
Publisher=型号。ForeignKey(Publisher)
发布日期=models.DateField()#