In my model a user can be linked to many accounts - to display this
I've got a multiple select on a manytomany field, I pass the user and
the list of all possible accounts to the template:

<select multiple>
    {% for account in accounts %}
        <option value="{{ account.id }}">{{account.name}}</option>
    {% endfor %}
</select>

This displays the account names in a multiple select box perfectly :-)

I would like to show which of these accounts are already linked to the
user but I'm not sure how to do it - something like:

<option value="{{ account.id }}"          {% if account.id in
user.accounts %}selected="True"{% endif %}
>{{account.name}}</option>

I feel really stupid asking as I'm sure the answer if obvious but I
just can't seem to get it working!

Many thanks
Liz


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to