views:

144

answers:

1

Hi!

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?

+2  A: 

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.

Van Gale
Nice!Know any different date widget, or is there any online repository of widgets I can browse?Thanks!
Andor
There are several widgets at http://www.djangosnippets.org including this one for splitting time fields into multiple inputs: http://www.djangosnippets.org/snippets/590/ You should be able to use that for a nice Date widget. There are also some projects that "collect" widgets into a single app, e.g. http://code.google.com/p/django-plus/ (can't think of any others atm).
Van Gale
All the snippets tagged as widgets: http://www.djangosnippets.org/tags/widget/
Van Gale