How to create a django form with a select list initialized from a dynamic query? -


i'm trying build form select list can initialized tuple parameter pass in on creation of form object.

i tried doing following, worked creating form. when try submit form, is_valid() = false error. in example below myrooms variable data i'd dynamically load upon initialization of form. here?

class sessioninfoform(forms.modelform):       def __init__(self, myrooms = none, *args, **kwargs):          super(sessioninfoform, self).__init__(*args, **kwargs)          if myrooms != none:              self.fields['room'].choices = myrooms       class meta:          model = sessioninfo          fields = ["title", "room", "viewer_limit", "starttime", "endtime", "billing_type", "billing_value"] 

your forgetting pass same list myrooms when validating results.

you have pass both rendering , validating.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -