On Mar 10, 5:57 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> Hi Laurie,
>
> On Sat, 2007-03-10 at 17:45 -0500, Laurie Harper wrote:
>
> [...]
>
> > I want Project needs to be a sub-type of Page (hence inheriting from
> > Page rather than just models.Model). Page.objects.all() should return
> > both Page and Project instances; inserting a Project should create a
> > row in the Page table; etc.
>
> > Given the restriction of the existing DB schema, is there anything I
> > can do? Is this supported by Django ORM? I know the OneToOneField
> > field type is 'deprecated' / subject to change, so ideally I'd like to
> > use a solution that doesn't require it, but I can live with it if I
> > need to (and potentially re-write some code later).
>
> We don't have model inheritance yet. However, all the design work (and a
> fair portion of the coding has been done) and it will work exactly as
> you want: one table per sub-class, by default. Doesn't help you now, I
> realise, but it's in the future. It will be in before 1.0 (but after
> 0.96).
>
> In the meantime, don't worry about the documentation note on
> OneToOneField (we really need to change that). There are no plans to
> remove it or change its behaviour in any significant way, since it's
> actually a useful field. It may undergo some "under the covers" changes,
> because it's implemented a bit differently from other relations at the
> moment, but I can't see the public API changing.
>
> Regards,
> Malcolm
>
>
>
> > Thanks,
>
> > L.

Good to knwo I can ignore the 'don't use this' warning :-) However,
I'm
having some trouble using the relationship. Using the example models
from the 'One-to-one relationships' page:

p = Place(name="p1",address="...")
r = Restaurant(place=p,serves_hot_dogs=True,serves_pizza=True)r.place
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/django/db/models/fields/related.py", line 165,
in __get__
    raise self.field.rel.to.DoesNotExist
DoesNotExist
r.nameTraceback (most recent call last):
  File "<console>", line 1, in ?
AttributeError: 'Restaurant' object has no attribute 'name'

It seems I can't access the 'parent type' instance/properties. If I
insert
a p.save() before constructing r, I can dereference p.place, but the
Restaurant instance still doesn't have the fields from Place.

Is the model inheritance implementation far enough along I could
grab it off a branch somewhere and fill in the blanks as needed?

L.


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to