Dear Django devs,

sorry to bother you here, but I posted to django-users first 
(https://groups.google.com/d/msg/django-users/WHnCxHkEVjE/9puR4youvwsJ) and 
there was no reply, so please let me re-try here:

I'm probably overlooking something very simple, but still cannot explain 
what the code below does wrong: 

With these models: 

    class Vorblendplan(models.Model): 
        # ... 
        pass 

    class Mitarbeiter(models.Model): 
        # ... 
        vbp = models.OneToOneField(Vorblendplan, null=True, blank=True, 
on_delete=models.SET_NULL) 

I try to make sure that a Mitarbeiter object has a proper (not None) vbp 
instance. In the manage.py shell: 

>>> ma = Mitarbeiter.objects.get(key="F426") 
>>> ma.vbp                                  # ok, initially "None" 
>>> ma.vbp = Vorblendplan() 
>>> ma.vbp.save() 
>>> ma.save() 

>>> ma = Mitarbeiter.objects.get(key="F426") 
>>> ma.vbp                                  # Why still "None"?? 

This, in contrast, works: 

>>> ma = Mitarbeiter.objects.get(key="F426") 
>>> ma.vbp                                  # "None" 
>>> v = Vorblendplan() 
>>> v.save() 
>>> ma.vbp = v 
>>> ma.save() 

>>> ma = Mitarbeiter.objects.get(key="F426") 
>>> ma.vbp                                  # ok, as expected 
<Vorblendplan: Vorblendplan object> 

Why does the first example not work? 

Any hint would very much  be appreciated!  :-)

Thank you very much, and best regards, 
Carsten

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to