Thank you Daniel, I found another way.
Best, Michael On 14 August 2015 at 23:17, Daniel H <[email protected]> wrote: > Hi Michael. > > First of all, setting the pk to the pk of a different model will do > nothing. > > You can do this however, using Foreign Keys > <https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ForeignKey> > > restaurant = models.ForeignKey('Restautant') > > Then declare a new hotel object like this: > > restaurant = Restaurant.objects.get(name='Will soon be a hotel') > Hotel.objects.create(restaurant=restaurant.pk) > > What does the "Place" table represent? > > > On Friday, August 14, 2015 at 7:35:26 AM UTC-7, [email protected] wrote: >> >> Hi all, >> >> suppose I have the following model structure >> >> from django.db import models >> >> class Place(models.Model): >> name = models.CharField(max_length=50) >> >> class Restaurant(Place): >> ... >> >> class Hotel(Place): >> ... >> >> I already have a Restaurant in my database. This Restaurant is now also >> becoming a Hotel. I would like to declare this in the database as follows: >> >> restaurant = Restaurant.objects.get(name='Will soon be a hotel') >> Hotel.objects.create(pk=restaurant.pk) >> >> Is this a safe thing to do? >> >> Thanks, >> Michael >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Django users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/django-users/26Qu9-wJ1gA/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/c270d98c-7a14-4870-9f04-3ccfcb3abeb3%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/c270d98c-7a14-4870-9f04-3ccfcb3abeb3%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- [image: Inline image 1] Michael Herrmann, MSc Alser Straße 18/26 1090 Wien Tel.: +43 699 11 65 16 40 Email: [email protected] -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABrKpmBK%3DY7oqufPj7OhmAT7WJ2i9t8XevuftO8-OS46BHWyjA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

