You're right, it could be done in form validation.  I'm not sure why I
feel compelled to validate everything at the model (or DB) level.

On Sep 29, 3:28 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Sep 29, 6:53 pm, ringemup <ringe...@gmail.com> wrote:
>
> > I have two models that are essentially identical except that for one
> > of them a couple of the fields can be blank/null that are required in
> > the other.  It seems silly to maintain two full implementations in
> > parallel, so I'd like to just make one model a subclass of the other.
> > I've looked through the docs, but I'm not clear on how to do this, or
> > whether it's even possible.  Any ideas?
>
> I don't think this is possible with Django's model inheritance
> features. However, I would question why you need it: this sort of
> thing is probably best managed at the form level, by having one set of
> forms with the relevant fields set to required=False, and one with
> required=True (and of course one form will probably subclass the
> other).
>
> Or even, if you need to set this dynamically based on the value of
> another field in the model (say, a set of choices) then you could use
> a single form with a custom clean() method to validate that if field x
> was set to one value, fields y and z are not required, but if it's set
> to another value, they are required.
>
> If neither of those are suitable, maybe you could post more details of
> your use case.
> --
> DR.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to