#12420: "OneToOneField doesn't allow assignment of None"
---------------------------------------------------+------------------------
          Reporter:  kbrownlees                    |         Owner:  andrewsk
            Status:  reopened                      |     Milestone:  1.2     
         Component:  Database layer (models, ORM)  |       Version:  SVN     
        Resolution:                                |      Keywords:          
             Stage:  Ready for checkin             |     Has_patch:  1       
        Needs_docs:  0                             |   Needs_tests:  0       
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Comment (by gsakkis):

 I don't think it's related, this dies fast and hard; I'm surprised it
 hasn't been noticed before. Using the models of #14043:

 {{{
 In [6]: bob = Person.objects.create(age=34)
 In [7]: bobs_soul = Soul.objects.create(person=bob)
 In [8]: bob.soul == bobs_soul
 Out[8]: True
 In [9]: bob.soul = None
 ---------------------------------------------------------------------------
 AttributeError                            Traceback (most recent call
 last)

 --> 258         setattr(value, self.related.field.attname,
 getattr(instance, self.related.field.rel.get_related_field().attname))
     259
     260         # Since we already know what the related object is, seed
 the related


 AttributeError: 'NoneType' object has no attribute 'person_id'
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12420#comment:13>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to