Maybe I should have made the context more clear.

First of all, we're not using ModelForms but just Django Forms.

It's true that when it's not filled correctly, the form returns the
validation but we have cases in which the data in the fields is not
returned when the form operation is not successful.

In those cases we copy the sent data in python and return that sent data,
filling the form with it, but we have achieved a better, more generic way
by JavaScript.

When the form operation is successful, we need the data no more, because is
already saved in database, so we want to clear it from HTML5 webStorage by
JavaScript.
El 19/9/2015 1:04 p. m., "Gergely Polonkai" <gerg...@polonkai.eu> escribió:

> Hello,
>
> I can't see the use case here. If you are submitting the form with AJAX,
> why would you store it? Or, if I misunderstood you and you submit in the
> non-AJAX way, Django will send give you back your filled form with the
> validation errors.
>
> Best,
> Gergely
> On 19 Sep 2015 10:09, "Martin Torre Castro" <mad...@gmail.com> wrote:
>
>> Hello,
>>
>> I have a django project where I make requests to the server views both by
>> AJAX and the usual  simple URL requests to Django.
>>
>> The thing is that I have made one javascript function for storing the
>> forms contents in the HTML5 webstorage and I want to clear the stored data
>> after coming from a succesful operation, beacuse the flow is:
>>
>> 1. You get to the form
>>
>> 2. You enter the data into the form
>>
>> 3. Press submit
>>    a. If there is a validation error, we come back to 3 and the
>> javascript function fills the same data entered into the form (this is
>> already done and is awesome and comfortable for the user)
>>
>> 4. If all data was valid and OK, after returning from the python/django
>> view I want to trigger the javascript function that clears the stored data,
>> because is saved and we don't need it anymore because it's already saved. 
>> *This
>> is my problem*
>>
>>
>> When returning to an AJAX I can simply use the success function in
>> jQuery.get() o jQuery.ajax(), but when returning from a regular view I
>> can't think of any strategy other than passing the flow to a success page,
>> in which I trigger the function with $(document).ready().
>>
>> I'm looking for the best alternative, because it would be better not
>> forcing me to pass through a specific page. Any ideas?
>>
>>
>> Thank you in advance.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/bffd59a7-c30f-4092-8160-30ef7e472b27%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/bffd59a7-c30f-4092-8160-30ef7e472b27%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/eZJ-mQgp9w0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACczBUKE741snUn-BKF9RUzJejFypsb-W4tamtS7NJdW6F06KA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CACczBUKE741snUn-BKF9RUzJejFypsb-W4tamtS7NJdW6F06KA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKijOky93WY-R2ofYZc3qLr8n%3DSo0Z2u-VDd1gdETX_m-Wamww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to