Re: Many to many fields to string

2010-08-12 Thread Steve Holden
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

Re: Many to many fields to string

2010-08-12 Thread Wendy
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 %}

Re: Many to many fields to string

2010-08-11 Thread Joseph Spiros
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.

Re: Many to many fields to string

2010-08-11 Thread Joseph Spiros
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

Re: Many to many fields to string

2010-08-11 Thread Carlos Daniel Ruvalcaba Valenzuela
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.

Many to many fields to string

2010-08-11 Thread Wendy
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