Django Suit not showing date & time widgets

448 views Asked by At

Im using Django 1.10 and Django-Suit 0.2.20 . Usually the DateFields DateTimeFields etc in the django admin show a widget with a calendar. After intalling Django-Suit I cant see that widget anymore. Is there any way put them back?

1

There are 1 answers

0
snakey On BEST ANSWER

I didn't find the solution how to make native django widgets working but there is a workaround to use suit widgets as defaults instead (taken from discussion on github):

from django.db import models as django_models
from django import forms
from django.contrib.admin.options import FORMFIELD_FOR_DBFIELD_DEFAULTS
import suit.widgets

FORMFIELD_FOR_DBFIELD_DEFAULTS.update({
    django_models.DateTimeField: {
        'form_class': forms.SplitDateTimeField,
        'widget': suit.widgets.SuitSplitDateTimeWidget
    },
    django_models.DateField: {'widget': suit.widgets.SuitDateWidget},
    django_models.TimeField: {'widget': suit.widgets.SuitTimeWidget},
})