[Django]-AttributeError: 'module' object has no attribute 'Datefield'

10πŸ‘

βœ…

It should be models.DateField with a capital F.

So your Books model should look like this:

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
πŸ‘€Shawn Chin

Leave a comment