Skip to content Skip to sidebar Skip to footer

Attribute Error 'module' Object Has No Attribute 'DateField'

I'm trying to extend an admin definition in Satchmo/Django and am getting the error 'Attribute Error 'module' object has no attribute 'DateField'' trying to add a formfield_overrid

Solution 1:

DateField is defined in django.db.models, notdjango.forms.models. You need to import django.db.models as well.

Perhaps use:

from django.db import models as db_models

formfield_overrides = {
    db_models.DateField: {
        'widget': AdminDateWidget,
        'input_formats': settings.VALID_DATE_FORMATS,
    },
}

Post a Comment for "Attribute Error 'module' Object Has No Attribute 'DateField'"