List Info

Thread: Displaying ManyToMany relation in template




Displaying ManyToMany relation in template
user name
2006-10-31 23:00:52
hi,

try something like the following:

>         {% if latest_posts %}
>                 {% for post in latest_posts %}
>                         <h2 id="post-{{ post.id
}}">
>                                 <a
href="">{{ post.title }}</a>
>                         </h2>
>                         <p
class="post-info">publié le {{
> post.pub_date|date:"l d F Y à H:i" }}, dans
la catégorie

{% for category in  post.category.all %}
	<a href="{{ category.get_absolute_url
}}">{{ category.title }}</a>
{% endfor %}

> </p>
>                         <div
class="post-content">{{ post.summary
}}</div>
>                         <div
class="post-tag">

{% for tag in post.tag.all %}
	{}
{% endfor %}

> </div> 
>                 {% endfor %}
>         {% else %}
>                 <p>Aucun article ne correspond
aux critères.</p>
>         {% endif %}

-> http://www.djangoproject.com/documentation/models
/many_to_many/

> Thanks in advance,
> Nicolas
-- 
you're welcome!

	Nikl

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )