3

ファイル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'

助けてください。

4

1 に答える 1

10

models.DateField大文字である必要がありますF

したがって、Booksモデルは次のようになります。

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
于 2012-12-19T16:02:23.597 に答える