Hi - got a bit of a tricky one, which I can't quite come up with a
sensible design pattern for:
I have a contact form, which appears on a number of different pages
across a site. To keep it generic and cut down on duplication of
code, my thinking was that I should create a templatetag to display it
wherever it is needed. It uses a Manipulator to inject the form into
the template's context, and looks something like this:
def generic_form(context):
manipulator = Contact.AddManipulator()
errors = new_data = {}
return {
'form': forms.FormWrapper(manipulator, new_data, errors),
}
register = template.Library()
register.inclusion_tag('tag_templates/generic_form.html',
takes_context=True)(generic_form)
That all works fine, but here's the killer: I want the form to POST to
the current URL, whch could potentially be any URL on the site, and
handle all of the validation / error handling in-situ. i.e. I want
the user to be able to submit the form on the page they are looking
at, and have that same page returned with the form updated with either
success or validation errors. My initial thinking was that a
dedicated view would be the way to go, which would redirect back to
the refering URL - but that creates all sorts of nightmares with
context and request variables!
Ultimately, this will use XMLHttpRequest to POST and refersh just the
form portion of the page, but I need a graceful non-JavaScript
solution too. My thinking is that it's just not going to be possible,
but just interested to know if anyone has ever done anything similar?
-Phil
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---