Problems saving data in form-model django

3

Sirs, good afternoon! I'm having a little problem, I made some changes to an application that I'm developing for studies. I come across the following, fill in the form all right and when I give a save, nothing happens, does not redirect to the list or anything. The stranger I look in the terminal of a post.  "POST / tickets / new / HTTP / 1.1" 200 3261 What can it be? I tried everything and I can not solve it.

Here is the code for the view: link Follow the model code: link Who could help me thank me.

    
asked by anonymous 11.09.2014 / 16:35

2 answers

1

Note that the response status was 200 which means that there was some form validation error and most likely a render() was executed at the end of the request.

If there was no validation error in form, the answer would be a redirect , with status 302 .

Therefore, I believe POST is failing in validation and the same page is being re-viewed by the browser. As suggested by @mgibsonbr.

    
18.09.2014 / 00:27
0

I'm not experienced with Form s, but most likely your problem is missing error indications in your template. This line in ticket_post :

if not form.is_valid():
        return render(request, 'ticket_novo.html',{'form': form})

You're saying, "If the validation fails, show the same page I'm already on, with the same form, with the same values I've passed." That is, it is quite possible that the action has changed pages, and you did not even notice it because the new page is identical to the old one (and page transitions are not always accompanied by a visual indication that something has happened .)

However, as this response in SOen if your template uses somehow forms.errors then the new page may visualize what went wrong. You say that "I fill in the form all right" but it does not show neither the Form nor the data you tried to pass, then you have to consider the possibility of having an error filling out the form (ie invalid data) / p>     

11.09.2014 / 18:25