Sunday, July 29, 2012

Re: form.save() fails silently - how to debug?

Just to follow up...

I have tried using pdb - but stepping into the Django code goes through hundreds of lines of records and, to be honest, its not clear at all what I should be looking for or where I would expect to see errors...  If there is any guidance in this respect, I would be happy to hear it.

As per Dan's suggestion, I have also tried stripping out all the non-model fields from the form, along with all the "funny" clean code (I now just have a straightforward return of the cleaned data). Again, no success: the cleaned data looks OK (in the print statement) but it is simply not saved.

On Friday, 27 July 2012 15:46:01 UTC+2, Derek wrote:
Thanks Karen

I am not quite sure what you mean by "Model save() would indicate an error" - I am making a call to the form.save(), which in turn, I assume, should result in the data being saved to the model (although nothing gets saved in my case)?  No error is being raised that I can see.  

I have not used pdb before; I will need to look into how that works and how might help me.

On Friday, 27 July 2012 14:00:37 UTC+2, Karen Tracey wrote:
On Fri, Jul 27, 2012 at 3:25 AM, Derek  wrote:
The clean() method basically stores the non-model field data in the model's dictionary field.  If this method was faulty, then it would also cause problems in the test code.  As I said, when I print the data to console it looks OK.  I am still trying to find how and where the save() method indicates errors...?

Model save() would indicate an error by raising an exception, see:

https://github.com/django/django/blob/master/django/db/models/base.py#L444

I would attack the problem you are seeing by tracing through what's actually happening using pdb.

Karen
--
http://tracey.org/kmt/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/SGKss8CoaXQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment