You can remove that entire pasted section of code and replace it with {{
form.activity }}, Django will render it with the behavior you described.

-James
On Jun 9, 2015 5:02 PM, "Vijay Khemlani" <[email protected]> wrote:

> It doesn't answer the question, but why don't you want to render the field
> automatically?
>
> On Tue, Jun 9, 2015 at 6:47 PM, <[email protected]> wrote:
>
>> Hi,
>>
>> I have the same problem of this guy (
>> http://stackoverflow.com/questions/21884631/keeping-option-selected-after-form-is-submitted-in-django),
>> but I do not want to render a field like Daniel Roseman
>> <http://stackoverflow.com/users/104349/daniel-roseman> said in the
>> answer.
>>
>> Here is the code:
>>
>> <select id="{{ form.activity.auto_id }}" name="{{ form.activity.name }}"  
>> data-size="10">
>>     {% for id, name in form.activity.field.choices %}
>>         {% if form.activity.value == id %}
>>             <option value="{{ id }}" selected>{{ name }}</option>
>>         {% else %}
>>             <option value="{{ id }}">{{ name }}</option>
>>         {% endif %}
>>     {% endfor %}
>> </select>
>>
>>
>> Thanks in advance.
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/a6a2db7a-e4b0-4281-b6db-6f31009ac68d%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/a6a2db7a-e4b0-4281-b6db-6f31009ac68d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei0cQOhZA1ae%3DVozqdL3uxERTpfinYRBx1CncGiu3Tepmw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALn3ei0cQOhZA1ae%3DVozqdL3uxERTpfinYRBx1CncGiu3Tepmw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVJg-R%3DOP1cn7wSMtecC5Y3%3DdnuO4xR%2BmGwy%3DP%2Bg9j7ZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to