HI,

Forgive me, here's another n00b doozie. I've created a form, which
extends form, however, my form is not validating and I can't get the
form to print errors next to my form fields. What's curious, at the
form.is_valid()
in all the examples, I don't see an else: clause. Which leads me to
believe that a validation error should be
raised at this point, so an else is not neccessary??

So, my form should hold clean_fieldname methods for each field name
correct? and if an error is raised,
automagically, django handles the error messages, as long as it's
defined in my template, correct or not?
So every property needs a clean method?

Sorry, I've read the resources and I'm a little unclear on this?

Thanks for your time,
Django and the community rocks

from my views:

def listing(request):
    if request.method == 'POST': # If the form has been submitted...
        new_listing = Listing()
        form = ListingForm(data=request.POST,instance=new_listing)
        #form.save()
        if form.is_valid(): # All validation rules pass
            form.save()
            return HttpResponseRedirect('/listing/') # Redirect after
POST
        #else:
            #return HttpResponseRedirect('/listing/') # Redirect after
POST
            #return HttpResponse('form is a failure, like you.')
            #return HttpResponseRedirect('/create/') # Redirect after
POST
    else:
        form = ListingForm() # An unbound form
        return render_to_response('listing.html', {
            'form': form,
        })


listing.html template

{% extends "base.html" %}
{% block content %}
<div id="content-main">
<form action="/create/" method="post">
   {% include "form_snippet.html" %}
   <input type="submit" value="Submit" />
</form>
{% endblock %}
so apparently that should work



form_snippet.html template

% for field in form %}
   <div class="fieldWrapper">
       {{ field.errors }}
       {{ field.label_tag }}: {{ field }}
   </div>
{% 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-us...@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.

Reply via email to