Thanks Karen for the reply.
I overlooked the ticket you mention.

Just for reference for others reading in the future this thread, here
is a simpler (and more portable) solution other than applying the
patch attached to http://code.djangoproject.com/ticket/7623.

If you modify the child model as follow (therefore bypassyng table
inheritance by setting an explicit OneToOne relation):
class Restaurant(models.Model):
    place_ptr=models.OneToOneField(Place, primary_key=True)
    serves_hot_dogs = models.BooleanField()
    serves_pizza = models.BooleanField()

everything works as expected also in the admin interface and the final
result is the same (although less elegant than multi table
inheritance).

Note that using place_ptr as the field name (the default name used by
the implicit OneToOne relation created by the multi inheritance
machinery), it is not necessary to change anything at the database
level: just change the model definition (and probably some definitions
in admin. py) and all is OK.

regards,

__peppo

On 20 Mag, 22:34, Karen Tracey <kmtra...@gmail.com> wrote:
> On Thu, May 20, 2010 at 4:26 PM, peppo <peppo.bone...@gmail.com> wrote:
> > I have the following problem with admin and multi table inheritance I
> > don't understand (django 1.1.1).
>
> > Model definition
>
> > class Place(models.Model):
> >    name = models.CharField(max_length=50)
> >    address = models.CharField(max_length=80)
>
> > class Restaurant(Place):
> >    serves_hot_dogs = models.BooleanField()
> >    serves_pizza = models.BooleanField()
>
> > In the admin pages for adding restaurant instances I see the field of
> > the parent class (name and address) and the parent instance get
> > created as expected.
>
> > How can I link directly to an _exixting_ Place instance?
> > If I fill in name and address in the child admin add page, then I get
> > duplicates in the parent table.
>
> > Is there a solution or I am missing something trivial?
>
> No, this is not currently supported by the ORM. There is a ticket requesting
> it:
>
> http://code.djangoproject.com/ticket/7623
>
> Karen
> --http://tracey.org/kmt/
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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