On 8/12/2010 8:11 PM, Wendy wrote:
> Thanks so much both of you, totally works and makes sense. I used
> Joseph's version because of the commas, but they both helped me
> understand what was happening.
> I notice that it seems to be ok to put the if statement on one line:
>
> {% if
Thanks so much both of you, totally works and makes sense. I used
Joseph's version because of the commas, but they both helped me
understand what was happening.
I notice that it seems to be ok to put the if statement on one line:
{% if filmmakers|length > 2 and not forloop.first %}, {% endif %}
Er, I forgot to add an {% endwith %} at the end. You don't HAVE to use
the with tag at all, but it can make things a bit easier.
On 8/11/10 6:18 PM, Joseph Spiros wrote:
> You'll want to loop through the objects and print the appropriate
> property of the objects that consists of just the name.
You'll want to loop through the objects and print the appropriate
property of the objects that consists of just the name. Here's some
template code that does that, and also separates with commas and "and",
using a serial comma (aka Oxford comma).
(This assumes that your Filmmaker model has a
Use a for loop, there is tags to know if you are at the last item of
the list, so to not add the and:
{% for filmmaker in film.filmmakers.all %}
{{ filmmaker.name }} {% if not forloop.last %} and {% endif %}
{% endfor %}
Assuming you are using django 1.2, but you get the idea.
Hello,
I'm just getting started, and I'm returning a many to many object in
my template:
p>{{ film.filmmakers.all }}
So it's displaying the list:
[, ]
Can anyone tell me how to return just a string of the names?
I'm still getting acclimated to python syntax.
Actually in a perfect world, it
6 matches
Mail list logo