Question

I'm configuring the admin site for my new app, and I found a little problem with my setup.

I have a 'birth date' field on my database editable via the admin site, but, the date widget isn't very handy for that, because it makes that, if I have to enter i.e. 01-04-1956 in the widget, i would have to page through a lot of years. Also, I don't want people writing the full date manually in only one edit box, as there are always problems with using dashes or slashes as a separator, or introducing date in European, American or Asian format...

What would McGyver ( I mean you ) do?

Was it helpful?

Solution

Use the formfield_overrides option to use a different widget. For example (untested):

class MyModelAdmin(admin.ModelAdmin):
    formfield_overrides = {
        models.DateField: {'widget': forms.TextInput},
    }

Then you'll need to do date conversion/validation yourself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top