The view is rendered as a series of template extensions from a master
base.html. Elements also use inclusion tags.
I want to include a form field in the main part of the view and have
displayed this as an inclusion tag. The purpose of the form is to
enable a user to enter a code which can be checked in the database.
Error messages need to be returned to this view, if code is valid the
user will be passed to a new view.
However, I'm not sure of the best way to process the form for error
messages without rebuilding the complete view, which seems to be a lot
of overhead when you consider all the relevant queries that have to be
re-done.
Can any one advise on best practice here, or a means by which I can
cache the original view?
Multiple way to process this in my opinion :
1- cache the elements of the page that can be cached with the django
caching api
2- use ajax to process your form. This will avoid the whole page to be
reload. For exemple when the form is fired, process an ajax request
and evaluate a JSON or HTML repsonse.
xav
Tim
http://www.b-list.org/weblog/2006/08/05/django-tips-simple-ajax-example-part-2
With YUI javascript library.
http://code.djangoproject.com/wiki/AJAX/Dojo/RefactoredFormSubmit
With DOJO javascript library.
http://code.djangoproject.com/wiki/AjaxPrototypeNewForms
With Prototype javascript library.
--
Glisha
The perfect OS, MS-DOS!
No patches, no root exploits for 21 years.
The JavaScript:
http://dpaste.com/hold/8571/
The Python:
http://dpaste.com/hold/8572/
The code might be a little weird looking. I'm relying on a 403
response header to detect validation errors and the X-Requested-With
request header to detect Ajax.
Feel free to drop me a line for more explanation if you want.
- whiteinge
I've read through all the links and I can see plenty of scope with
Ajax/JSON.
I note that most of the solutions use a Javascript toolkit such as
Prototype/Dojo/Yahoo/JQuery. Two questions come to mind:
1. Does using the toolkit save a lot of work - what are the main
advantages?
2. How do you choose between them?
Tim
On Apr 18, 8:26 pm, Nathaniel Whiteinge <whitei...@gmail.com> wrote:
> Personally, I use a toolkit to lessen cross-browser compatibility
> problems as well as to speed quick, little functionality (eg.
> animations). I chose jQuery because it's small, unobtrusive, and I
> love the CSS-like syntax.
> - whiteinge
>
Thanks - I can see the reasoning. We've used JQuery on a small PHP
site we did, but only to provide some nice tab effects. It was
reasonably straightforward to use, even for a JS novice. Will give it
a go on our Ajax work in Django too.
-Tim