Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I have a django form CreateQuoteRequestForm and I wanted to populate a list of items from a query set. So I created a list and then assigned as seen below. The form and select box work well. Are there any caveats or issues with assigning data to a form in this manner?

   quoteform = CreateQuoteRequestForm()
   quoteform.fields.get('name').choices=event_list
share|improve this question

1 Answer

up vote 1 down vote accepted

It doesn't feel quite Djangonic. Instead of futzing with the fields after the fact, pass a keyword argument to the constructor, and in the initializer set the field choices and remove the keyword argument from the dictionary.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.