Re: Strip empty lines in rendered templates?
Or simply remove the return after the forloop statement. Like so. {% for entry in entries %}{{ entry.title }} {% endfor %} should give you Title 1 Title 1 Title 1 On Mar 15, 9:13 pm, Benjamin Buch wrote: > Hi, > > is there a way to tighten up the output that Django renders? > Especially, remove the empty lines? > > This template code: > > > {% for entry in entries %} > {{ entry.title }} > {% endfor %} > > > looks like this when rendered: > > > > Title 1 > > Title 1 > > Title 1 > > > > I stumbled upon this > middleware,http://code.djangoproject.com/wiki/StripWhitespaceMiddleware, > but the discussion around it is somewhat dated, > and even the author states that there are some problems with > it.http://code.djangoproject.com/wiki/ContributedMiddleware > > Is there any other way to handle it? > > benjamin --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Update a a single field
Aah yes that worked. Thanks Daniel. To clarify my own thoughts, a python example: For example, setattr(x, 'foobar', 123) is equivalent to x.foobar = 123 On Nov 3, 3:44 pm, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Nov 3, 1:41 pm, "darryl.hebbes" <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > I want to do something like this, I wish to make the 'fieldname' > > dynamic, I am just trying to update a field without a hard coded > > name... the name is passed in via a form. > > > --- > > def updateProfile(request): > > fieldname = request.POST["id"] > > fieldid = int(request.POST["profileid"]) > > fieldvalue = request.POST["value"] > > pe = Profile.objects.get(id=fieldid) > > pe.[fieldname] = fieldvalue # <--- I want to pass the name of the > > field to save() > > pe.save() > > return HttpResponse('Saved we hope', mimetype="application/json") > > --- > > > Hope this makes sense. > > > Darryl. > > If I understand correctly, you want setattr: > > setattr(pe, fieldname, fieldvalue) > -- > DR. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Update a a single field
Hi, I want to do something like this, I wish to make the 'fieldname' dynamic, I am just trying to update a field without a hard coded name... the name is passed in via a form. --- def updateProfile(request): fieldname = request.POST["id"] fieldid = int(request.POST["profileid"]) fieldvalue = request.POST["value"] pe = Profile.objects.get(id=fieldid) pe.[fieldname] = fieldvalue# <--- I want to pass the name of the field to save() pe.save() return HttpResponse('Saved we hope', mimetype="application/json") --- Hope this makes sense. Darryl. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---