With the hack i think you mean, it doesn't matter, just pick one, the
point of the hack is you just shamelessly lie to the django ORM. So make
sure to make your model ummanaged and _don't_ try to save.
Excellent. Yeah, I'd been planning on overriding save() to make it raise NotImplementedError (it's a read-only database after all).
I'm not sure about django 1.2+ model validation with the hack, though,
or even just django 1.2. We use the hack - but presently with 1.1.
Good deal. I'd be targeting 1.2+ so I'll just have to wait and see I guess.
Looking at the docs, you're presumably not using a ModelForm, and if
you're explicitly using Model.full_clean() or clean_fields() you can
probably pass in an exclude=... to exclude the field(s) that you're
lying to django about if need be. Based on the docs rather than
experience, I don't think django model calls validators on initial
load/init, it has to be by ModelForm calling them on the model, or just
explictly calling one of the model clean methods.
Ok, great. If validation only takes place during operations normally associated with insert/update (like ModelForm.save(), or Model.save()), I should be good to go. I just started to wonder if the ORM would, I don't know... "freak out" on the off-chance I run a query that returns a set of objects with duplicate values on what is supposed to be the pk.
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment