Tuesday, July 31, 2012

Re: form.errors is not a dictionary?

I too have the same problem. How did you fix it?

On Wednesday, April 6, 2011 2:13:48 AM UTC+5:30, Roy Smith wrote:
I'm using django-1.3 .  I have a view with the following code:

def item_create(request):
    if request.method == 'POST':
        form = ItemForm(request.POST)
        if form.is_valid():
            url = form.cleaned_data['url']
            item.save()
            return HttpResponseRedirect('/')
        else:
            print form.errors

when I submit the form, I expected that form.errors would print out as
a dict, as documented in http://docs.djangoproject.com/en/1.3/ref/forms/api/#using-forms-to-validate-data.
Instead, I'm getting a hunk of HTML:


Django version 1.3, using settings 'soco-site.settings'
Development server is running at http://0.0.0.0:7626/
Quit the server with CONTROL-C.
<ul class="errorlist"><li>date_added<ul class="errorlist"><li>This
field is required.</li></ul></li><li>user_id<ul
class="errorlist"><li>This field is required.</li></ul></li></ul>
[05/Apr/2011 16:36:32] "POST /item/create/ HTTP/1.1" 200 718

Is my understanding wrong, or is this a bug?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/-zDMLV9xjogJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment