[openstack-dev] [horizon] Initial value of form.ChoiceField while editing

Gabriel Hurley Gabriel.Hurley at nebula.com
Thu Oct 11 19:31:02 UTC 2012


You can certainly set the initial value of a ChoiceField. As long as the choices have been set, you can pass in the "value" of the choice you want to set (e.g. the first element in the choices tuple) when initializing the form in your view and it will work just fine. Make sure you don't have any problems such as the choice you want to select not being in the list of available choices, or a mismatch between strings and integers or anything of that sort.

    - Gabriel

> -----Original Message-----
> From: Rahul Sharma [mailto:rsharma at contrailsystems.com]
> Sent: Tuesday, October 09, 2012 1:04 AM
> To: OpenStack Development Mailing List
> Subject: [openstack-dev] [horizon] Initial value of form.ChoiceField while
> editing
> 
> Hi,
> I am trying to use a form.ChoiceField, while editing it does not set the initial
> value unlike CharField. I read about django's problems with setting initial
> value of ChoiceField in forms, any solution in Horizon?
> 
> -
> Rahul
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev





More information about the OpenStack-dev mailing list