Re: How to get child model' name from parent obj in Multi-table inheritance

2008-06-01 Thread jonknee
On Jun 1, 1:46 am, David Zhou <[EMAIL PROTECTED]> wrote: > Why wouldn't that work, unless I'm misunderstanding something? > >  From the docs: > >  >>> p = Place.objects.filter(name="Bob's Cafe") > # If Bob's Cafe is a Restaurant object, this will give the child class: >  >>> p.restaurant > > Howe

Re: How to get child model' name from parent obj in Multi-table inheritance

2008-05-31 Thread David Zhou
On May 30, 2008, at 11:20 AM, jonknee wrote: > On May 30, 10:38 am, David Zhou <[EMAIL PROTECTED]> wrote: >> You can use also use hasattr(). >> >> Something like >> >> if hasattr(person_obj, 'man'): >> #is man >> elif hassattr(person_obj, 'woman'): >> #is woman >> else: >> #is freakish mutated

Re: How to get child model' name from parent obj in Multi-table inheritance

2008-05-31 Thread jonknee
On May 30, 11:20 pm, "David.D" <[EMAIL PROTECTED]> wrote: > If there are lots of child model, use hasattr() or capture exception > will not be good? > "add a type field to Person() and overide the save fields on Man and > Woman to set the type field correctly. " will be better? hasattr() doesn't

Re: How to get child model' name from parent obj in Multi-table inheritance

2008-05-30 Thread David.D
If there are lots of child model, use hasattr() or capture exception will not be good? "add a type field to Person() and overide the save fields on Man and Woman to set the type field correctly. " will be better? On May 30, 10:38 pm, David Zhou <[EMAIL PROTECTED]> wrote: > On May 30, 2008, at 2:5

Re: How to get child model' name from parent obj in Multi-table inheritance

2008-05-30 Thread jonknee
On May 30, 10:38 am, David Zhou <[EMAIL PROTECTED]> wrote: > You can use also use hasattr(). > > Something like > > if hasattr(person_obj, 'man'): >     #is man > elif hassattr(person_obj, 'woman'): >     #is woman > else: >     #is freakish mutated thing > How would that work exactly? It's a rev

Re: How to get child model' name from parent obj in Multi-table inheritance

2008-05-30 Thread David Zhou
On May 30, 2008, at 2:54 AM, [EMAIL PROTECTED] wrote: > Guess and test using try; except; statements. Alternatively, you > could add a type field to Person() and overide the save fields on Man > and Woman to set the type field correctly. > > On May 30, 1:38 am, "Davide.D" <[EMAIL PROTECTED]> wro

Re: How to get child model' name from parent obj in Multi-table inheritance

2008-05-29 Thread [EMAIL PROTECTED]
Guess and test using try; except; statements. Alternatively, you could add a type field to Person() and overide the save fields on Man and Woman to set the type field correctly. On May 30, 1:38 am, "Davide.D" <[EMAIL PROTECTED]> wrote: > Simplify the question: > > I got a "person", and how to kn

Re: How to get child model' name from parent obj in Multi-table inheritance

2008-05-29 Thread Davide.D
Simplify the question: I got a "person", and how to know the "person" is a "man" or a "woman" ? --~--~-~--~~~---~--~~ 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@

How to get child model' name from parent obj in Multi-table inheritance

2008-05-29 Thread Davide.D
Multi-table inheritance model example === class Person(models.Model): name = models.CharField(maxlength=10) height = models.SmallInteger() class Man(Person): job = models.CharField(maxlength=20) class Woman(Person): ma