Django

Code

Show
Ignore:
Timestamp:
06/04/08 19:39:32 (3 months ago)
Author:
jacob
Message:

Fixed #6886: Tightened up ForeignKey? and OneToOne? field assignment. Specifically:

  • Raise a ValueError? if you try to assign the wrong type of object.
  • Raise a ValueError? if you try to assign None to a field not specified with null=True.
  • Cache the set value at set time instead of just at lookup time.

This is a slightly backwards-incompatible change; see BackwardsIncompatibleChanges for more details.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/modeltests/one_to_one/models.py

    r7477 r7574  
    8181<Place: Ace Hardware the place> 
    8282 
    83 # Set the place back again, using assignment in the reverse direction. Need to 
    84 # reload restaurant object first, because the reverse set can't update the 
    85 # existing restaurant instance 
     83# Set the place back again, using assignment in the reverse direction. 
    8684>>> p1.restaurant = r 
    87 >>> r.save() 
    8885>>> p1.restaurant 
    8986<Restaurant: Demon Dogs the restaurant>