hi oscar,

how do you make use of the particular method to be able to render the form
only? as you said make use of the
https://docs.djangoproject.com/en/1.4/ref/contrib/csrf/#ajax  and it able
to render the form instead of page?
because i'm using kurtis method, if any validation error, i retrieve the
data from javascript and manipulate the
output in html only.

Regards,
MH

On Fri, May 4, 2012 at 1:58 AM, Oscar Mederos <omede...@gmail.com> wrote:

> Hello Kurtis,
>
> On Thursday, May 3, 2012, 3:16:38 PM, you wrote:
>
> > Here's something I do.
>
> > I have a page where I include {% csrf_token %} and another field.
> > Then I do a simple JQuery .post() call.
>
> > Note, I've tried to pull out a bunch of stuff that isn't specific
> > to the call. It's untested in this form but should work. I tried to
> > include comments to help you understand what's going on.
>
> > <script type="text/javascript">
> > $('div.theme_image, div.theme_name').on("click", function(event) {
> >
> >     // Used later to access 'this' (the calling object)
> >     var theme = this;
> >
> >     // Prepare our AJAX Call.
> >     url = '{% url fireflie.wizard.api.choose_theme %}'; // The URL to
> the View we're posting to.
>
> >     // Building the POST data here.
> >     data = {
> >         theme_id: $(this).siblings('input').attr('value'),
> >         csrfmiddlewaretoken:
> > $('input[name=csrfmiddlewaretoken]').attr('value')
> >     };
> >
> > ...
> >
> > });
> > </script>
>
> Hello,
>
> Another good option for passing the csrf token is the following one:
> https://docs.djangoproject.com/en/1.4/ref/contrib/csrf/#ajax.
>
> That helped me a lot, because sometimes you need to render your form
> again if it contains errors, and in that case, if you submit it again,
> the csrf token won't get updated correctly.
>
> Just imagine the case where the user wants to change his password:
> - He clicks on "Change password"
> - A modal form (dialog) appears
> - The user clicks on "Submit" and he didn't enter the two passwords
> correctly.
> - The form is rendered again (what I usually do is replace the
> <form>..</form> content with the some HTML returned by the server in
> the AJAX response). That HTML usually is the rendered form, so that I
> don't need to go for each field and set the errors manually using JS.
>
> > Good luck!
> > -Kurtis Mullins
>
>
> --
> Oscar Mederos
> omede...@gmail.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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