thx Karen it's true, strange, but so it is
On 1. Okt, 17:41 h., Karen Tracey <kmtra...@gmail.com> wrote: > On Thu, Oct 1, 2009 at 10:29 AM, gentlestone <tibor.b...@hotmail.com> wrote: > > > I have this model: > > > from django.db import models > > > class Subjekt(models.Model): > > """ > > >>> osoba = Osoba(meno = "Ludmila", priezvisko = "Safarova") > > >>> osoba > > <Osoba: Safarova Ludmila> > > >>> subjekt = Subjekt(nazov = "Zaba s.r.o.", osoba = osoba) > > >>> subjekt > > <Subjekt: Zaba s.r.o. - Safarova Ludmila> > > >>> subjekt.osoba.save() > > >>> subjekt.osoba > > <Osoba: Safarova Ludmila> > > >>> subjekt.osoba.id > > 1 > > """ > > [further description of problem with save() of subjekt snipped] > > At the time you create the subjekt instance, the related osoba instance has > not been saved. Therefore it does not have an id. If you check > subjekt.osoba_id, you will see it does not exist. It is subjekt.osoba_id > that is stored in the table and it not existing it what leads to the error > on save. (The value will not be pulled from subjekt.osoba.id on save() of > subjekt, it is only set when osoba is assigned to subjekt.) You should > save() the osoba instance before creating the related subjekt instance. > > Karen --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---