As far as I understand, you want to iterate over all form fields. Someone correct me if I'm wrong, but I've never seen anyone trying to achieve this via list(form).
Anyway, forms are iterable, so you can iterate over them in the templates:
https://docs.djangoproject.com/en/dev/topics/forms/#looping-over-the-form-s-fields
Am Samstag, 31. August 2013 01:06:31 UTC+2 schrieb Gerd Koetje:
-- Anyway, forms are iterable, so you can iterate over them in the templates:
<form action="/contact/" method="post"> {% for field in form %} <div class="fieldWrapper"> {{ field.errors }} {{ field.label_tag }} {{ field }} </div> {% endfor %} <p><input type="submit" value="Send message" /></p> </form>
https://docs.djangoproject.com/en/dev/topics/forms/#looping-over-the-form-s-fields
Am Samstag, 31. August 2013 01:06:31 UTC+2 schrieb Gerd Koetje:
Why does list(form) make my form not safe anymore?<code>@login_requireddef create(request):if request.POST:logger.debug('>>>>>>>>>>>POST POST POST<<<<<<<<<<<<<<<')form = ProfielenForm(request.POST, instance=request.user.profile)if form.is_valid():form.save()return HttpResponseRedirect('/profielen/all') else:user = request.userprofile = user.profileform = ProfielenForm(instance=profile) args = {}args.update(csrf(request))args['context_instance'] = RequestContext(request)args['form'] = list(form)return render(request, 'create_profiel.html', args)</code>
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.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment