See:
http://www.djangoproject.com/documentation/models/one_to_one/

On 6 November 2010 14:47, ringemup <ringe...@gmail.com> wrote:

> I can't find that example in this documentation [1].  Is there other
> documentation that I'm not aware of?
>
> [1]
> http://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-inheritance
>
>
> On Nov 6, 5:59 am, Derek <gamesb...@gmail.com> wrote:
> > The example shown in the online documentation.
> >
> > On 5 November 2010 18:24, ringemup <ringe...@gmail.com> wrote:
> >
> > > **{} is sort of the inverse of **kwargs in a function signature --
> > > it's a way to use a dictionary in place of keyword arguments, and
> > > should function identically.
> >
> > > Which "original example" are you referring to?
> >
> > > On Nov 5, 10:25 am, Derek <gamesb...@gmail.com> wrote:
> > > > You mean "trying to add a Restaurant which is linked to an existing
> > > place"
> >
> > > > I am not familar with the syntax you are using for the **{} wrapper.
> >
> > > > The original example shows:
> >
> > > > r = Restaurant(place=p1, serves_hot_dogs=True, serves_pizza=False)
> >
> > > > and the attached note says:
> >
> > > > Pass the ID of the "parent" object as this object's ID.
> >
> > > > Are you sure that the place ID is, in fact, what is being
> transferred?
> >
> > > > On 5 November 2010 15:59, ringemup <ringe...@gmail.com> wrote:
> >
> > > > > I'm not trying to create a Restaurant without a name and address.
>  I'm
> > > > > trying to turn an existing Place into a Restaurant.
> >
> > > > > On Nov 5, 9:42 am, derek <gamesb...@gmail.com> wrote:
> > > > > > Its not clear exactly what you think the problem is.  The system
> is
> > > > > > behaving correctly ito the way you have set it up.
> >
> > > > > > 1. You have specified that name and address are compulsory fields
> in
> > > > > > Place.
> > > > > > 2. You have specifed that Restaurant must be linked to Place
> (i.e.
> > > > > > Place must be created before Restaurant can be created)
> >
> > > > > > So why would you now want an entry in Restaurant that does _not_
> have
> > > > > > a name and address?
> >
> > > > > > On Nov 4, 10:25 pm, ringemup <ringe...@gmail.com> wrote:
> >
> > > > > > > I have an existing model that I want to extend using
> multi-table
> > > > > > > inheritance.  I need to create a child instance for each parent
> > > > > > > instance in the database, but I can't figure out how.  I've
> scoured
> > > > > > > google and haven't come up with anything other than Ticket
> > > #7623[1].
> > > > > > > Here are some of the things I've tried...
> >
> > > > > > > Let's adapt the Place / Restaurant example from the docs:
> >
> > > > > > > class Place(models.Model):
> > > > > > >     name = models.CharField(max_length=50)
> > > > > > >     address = models.CharField(max_length=80)
> >
> > > > > > > class Restaurant(Place):
> > > > > > >     place = models.OneToOneField(Place, parent_link=True,
> > > > > > > related_name='restaurant')
> > > > > > >     serves_hot_dogs = models.BooleanField()
> > > > > > >     serves_pizza = models.BooleanField()
> >
> > > > > > > I want to do the following, in essence:
> >
> > > > > > > for place in Place.objects.all():
> > > > > > >   restaurant = Restaurant(**{
> > > > > > >     'place': place,
> > > > > > >     'serves_hot_dogs': False,
> > > > > > >     'serves_pizza': True,
> > > > > > >   })
> > > > > > >   restaurant.save()
> >
> > > > > > > Of course, doing this tries to also create a new Place
> belonging to
> > > > > > > the new Restaurant, and throws an error because no values have
> been
> > > > > > > specified for the name and address fields.  I've also tried:
> >
> > > > > > > for place in Place.objects.all():
> > > > > > >   restaurant = Restaurant(**{
> > > > > > >     'serves_hot_dogs': False,
> > > > > > >     'serves_pizza': True,
> > > > > > >   })
> > > > > > >   place.restaurant = restaurant
> > > > > > >   place.save()
> >
> > > > > > > This, however, doesn't create any records in the restaurant
> table.
> >
> > > > > > > Any suggestions?
> >
> > > > > > > [1]http://code.djangoproject.com/ticket/7623
> >
> > > > > --
> > > > > 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<django-users%2bunsubscr...@googlegroups.com>
> <django-users%2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@googlegroups.com>
> >
> > > <django-users%2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@googlegroups.com>
> <django-users%252bunsubscr...@googlegroups.com<django-users%25252bunsubscr...@googlegroups.com>
> >
> >
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://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<django-users%2bunsubscr...@googlegroups.com>
> <django-users%2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@googlegroups.com>
> >
> > > .
> > > For more options, visit this group at
> > >http://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<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://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