I was in the same situation as you and I found this solution...
in your models.py:

import datetime
YEAR_CHOICES = []for r in range(1980,
(datetime.datetime.now().year+1)):    YEAR_CHOICES.append((r,r))


so, your field can now use YEAR_CHOICES:

year = models.IntegerField(_('year'), max_length=4,
choices=YEAR_CHOICES, default=datetime.datetime.now().year)



On Mon, Feb 20, 2012 at 3:47 PM, grimmus <graham.col...@gmail.com> wrote:

> Hi,
>
> I have a car model that contains many fields including a 'year' field. I
> need the dropdown for this field to display the current year as the first
> option and also display the previous 25 years as individual options.
>
> I was thinking i could create a list object and then populate the list
> based on the current year and work my way back to 25 years earlier.
>
> I am not sure how to implement this so it would work in the Django admin
> area.
>
> Could someone please point me in the right direction with this ?
>
> Thank you in advance.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/NUO22GxW7UEJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
This e-mail and any file transmitted with it is intended only for the
person or entity to which is addressed and may contain information that is
privileged, confidential or otherwise protected from disclosure. Copying,
dissemination or use of this e-mail or the information herein by anyone
other than the intended recipient is prohibited. If you are not the
intended recipient, please notify the sender immediately by return e-mail,
delete this communication and destroy all copies.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to