I've got a model where I need to store birth year. I'm using django admin. The person using this will be filling out loads of people every day, and DateField() shows too much (not interested in the day/month).

As you can see, most of the people is 17 years old, so I'm getting their birth year as default.

Can I do this better? How can I make a YearField out of the DateField? If making a YearField I can maybe even make some "easy tags" like the "now" that date has. (Of course, a specialized BornYearField would have easy buttons for 1989, 1990, 1991 and other common years)

3 Answers
3

Also, and this isn't that relevant for your case, but is useful being aware of, don't use datetime.date.today(), or datetime.datetime.now() as defaults. This is executed once, when the server is started up.

Yes, I knew that problem. However, I thought since this is a year field merely to help the people putting in new members all day, it only needs update once a year. It just needs to «almost hit» the avarage age. But thank you, of course a lambda solution is better.
–
VelmontOct 6 '09 at 11:19

5

Is it just me or this upvoted answer is not about the question ?
–
Ad NMar 5 '13 at 15:19