Django: Select option in template

You’ll want to pass the currently selected org into the view, maybe as current_org so that when you’re iterating through the orgs you can compare with the current one to determine whether or not to select it, like:

{% for org in organisation %}
   <option value="{{org.id}}"
       {% if org == current_org %}selected="selected"{% endif %}>
       {{org.name|capfirst}}
   </option>
{% endfor %}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)