Thursday, September 18, 2014

Re: Simple task. Get request.META values listed on a page via template

simple ways is using form and passing values to the template from the form.
https://docs.djangoproject.com/en/dev/topics/forms/

Many thanks,

Serge


+380 636150445
skype: skhohlov

On Mon, Sep 8, 2014 at 7:08 PM, Артём Мутерко <giliardi.arts@gmail.com> wrote:
I need to list all values from request.META in Django using template.

I've done it without template like this
(code from my views.py)

def display_meta(request):
  values = request.META.items()
  values.sort()
  html = []
  for k, v in values:
      html.append('<tr><td>%s</td><td>%s</td></tr>' % (k, v))
  return HttpResponse('<table>%s</table>' % '\n'.join(html))

For example I have template 'values.html', how can I do the same as above but using template and not hardcoding html in views.py?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4673f20b-aa76-4012-882b-fa370299ba1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADTRxJNOSFmZpW5CZi_S2CWtuftLF%2B%2BtkFzzaht98kLuTpj-Aw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment