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
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
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
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
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
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
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
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@
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
9 matches
Mail list logo