On Thu, Aug 20, 2009 at 4:11 AM, WilsonOfCanada<w...@sfu.ca> wrote: > > Hellos, > > I was wondering if there is a filter that can remove these '\' that > python added when strings are appended to a list or dictionary. I > cannot use cut because I still need one of the '\' > > ex. C:\\moo > > Code: > > arrPlaces = [] > intPoint =0 > > while (len(testline)): > testline = fileName.readline() > print testline > arrPlaces[intPoint].append(testline) > intPoint += 1 > > d["places"] = arrPlaces > return render_to_response('rentSearch.html', d) > >> C:\moo >> C:\supermoo > > the HTML using Django has: > > {{ places|safe }} but returns ['C:\\moo', 'C:\\supermoo']. I was > wondering of there is a filter for the template that would return ['C: > \moo', 'C:\supermoo'] instead. >
Indeed there is. It's not a filter but the correct way to do it: [{% for place in places %}'{{ place }}'{% if not forloop.last %}, {% endif %}{% endfor %}] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---