On Tue, Apr 11, 2006 at 06:19:49PM -0000, arthur debert wrote: > the thing is, if there's anything in django's knowledge to avoid the > save / delete it DOES raise an error. (such as trying to delete an non > existant object or trying to save a model that does not pass > validation). my guess here is if you need anything else in you logic > that django doesn't know about (from validators and the db) you must > implement it yourself.
Thanks. I was my understanding that validators were a "view" thing... even though you define the validator_list in the model. I thought that because the data passed to a validator is NOT the actual data that will be stored into the field(s) in question. i.e. from http://www.djangoproject.com/documentation/forms/#validators "Note that at the point validators are called all data will still be strings (as do_html2python hasn't been called yet)." So... are validators called automatically before any data is stored into a model's "field"? Or, are the validators actually called only as part of the form / view???? > try: > amodel.delete() > except: > return HttpResponseRedirect("bad_detele_action") > > or something to that effect. Right... I can write all of my save/delete/etc. code around a "try". But shouldn't this be a part of the "official" api -- either all such destructive methods might raise an exception (so you should be prepared for it), or all such destructive methods must return a boolean indicating success/failure (and you should check for it)...???? Plus, if I do code it that way, then how will the admin work against my models that raise exceptions???? Will the admin try for exceptions in save etc.? (sorry, but because I had one bad __repr that didn't return a string and it did NOT get caught by a "try", I'm not making any assumptions...) > maybe the so called validation aware models in m-r will do it? > http://groups.google.com/group/django-developers/browse_frm/thread/4bc65cf676c93846/5d7db0f7a5f85006?q=validation+aware&rnum=2#5d7db0f7a5f85006 I like the idea that the model should use a validator... but... is that the way it DOES work in M-R? Do all "fields" of a model actually invoke their validators? -- Glenn --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---