Search code examples
pythondjangodatabasedjango-modelsmode

AttributeError: module 'django.db.models' has no attribute 'DataField'


i tried running my server then i got this updated_at=models.DataField(auto_now_add=True) AttributeError: module 'django.db.models' has no attribute 'DataField'

Based on the line of the error, here is the code exactly where the error was detected.

    id=models.AutoField(primary_key=True)
    name=models.CharField(max_length=225)
    email=models.CharField(max_length=224)
    password=models.CharField(max_length=225)
    created_at=models.DateField(auto_now_add=True)
    updated_at=models.DataField(auto_now_add=True)
    objects=models.Manaager()

Kindly help me as i am new to python


Solution

  • You wrote DataField, instead it should DateField. Also Manaager should be Manager. Your code should look like this:

        id=models.AutoField(primary_key=True)
        name=models.CharField(max_length=225)
        email=models.CharField(max_length=224)
        password=models.CharField(max_length=225)
        created_at=models.DateField(auto_now_add=True)
        updated_at=models.DataField(auto_now_add=True)
        objects=models.Manager()