Django Admin: DateField (Year and Month) only

3,676 views
Skip to first unread message

The Danny Bos

unread,
Oct 19, 2009, 7:28:26 PM10/19/09
to Django users
Hiya,

In the Django Admin for the DateField I only want to display the Year
and Month as select lists. I'll default the day to the 1st every time.
Is this possible?

I want to keep the dates very simple, as I'll be adding many items
from 1900 to now. So using the current DateField calendar in Django
Admin would be an absolute nightmare.

Any ideas?

Joshua Russo

unread,
Oct 19, 2009, 7:38:14 PM10/19/09
to django...@googlegroups.com
Your best bet is to extend the date form field and input widget.  

The Danny Bos

unread,
Oct 19, 2009, 7:40:05 PM10/19/09
to Django users

APologies for my naivety, how would I do that.
Any examples you can point me toward?

Thanks for the fast reply,


d



On Oct 20, 10:38 am, Joshua Russo <josh.r.ru...@gmail.com> wrote:

Joshua Russo

unread,
Oct 19, 2009, 7:52:02 PM10/19/09
to django...@googlegroups.com
I don't have an example of a date field but here is an example of how I extended the Decimal field in making a Currency field.


In the description there are also links to the entire series of objects, including an input widget. That should get you started on the concept of extending fields and widgets.
Reply all
Reply to author
Forward
0 new messages