List Info

Thread: NOOB: default value in the ChoiceField?




NOOB: default value in the ChoiceField?
country flaguser name
United States
2007-02-27 13:19:38
Is there a way to set the initial or default value in the
ChoiceField?  I need to set a default Country.

For example:

    country = forms.ChoiceField(label='Country',
                                 choices=[(c.id,c.name) for
c in
Countrylist.objects.all()],
                                 default = ???
                                 )


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


Re: NOOB: default value in the ChoiceField?
country flaguser name
United States
2007-02-27 16:50:26
Use the 'initial' keyword arg:

http://www.djangoproject.com/documentation/newforms/
#initial

--
Jeff Bauer
Rubicon, Inc.


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


Re: NOOB: default value in the ChoiceField?
country flaguser name
United States
2007-02-27 19:52:33
I put in initial as a parameter.  In the drop down list, or
radio
button, it does not highlight it anyway when you are at the
page.  If
I look at the view source, it says, selected for drop down
list and
checked for radio button.  Any idea why?

On Feb 27, 5:50 pm, "Rubic" <rubi...gmail.com> wrote:
> Use the 'initial' keyword arg:
>
> http://www.djangoproject.com/documentation/newforms/
#initial
>
> --
> Jeff Bauer
> Rubicon, Inc.


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


Re: NOOB: default value in the ChoiceField?
country flaguser name
United States
2007-02-27 20:57:18
It's working now.  Thank you.

On Feb 27, 8:52 pm, "johnny" <rampet...gmail.com> wrote:
> I put in initial as a parameter.  In the drop down
list, or radio
> button, it does not highlight it anyway when you are at
the page.  If
> I look at the view source, it says, selected for drop
down list and
> checked for radio button.  Any idea why?
>
> On Feb 27, 5:50 pm, "Rubic" <rubi...gmail.com> wrote:
>
> > Use the 'initial' keyword arg:
>
> >http://www.djangoproject.com/documentation/newforms/
#initial
>
> > --
> > Jeff Bauer
> > Rubicon, Inc.


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


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )