diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index e3677c2..e6f651d 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -225,6 +225,17 @@ class ReverseSingleRelatedObjectDescriptor(object):
     def __set__(self, instance, value):
         if instance is None:
             raise AttributeError, "%s must be accessed via instance" % self._field.name
+        
+        # If null=True, we can assign null here, but otherwise the value needs
+        # to be an instance of the related class.
+        if value is None and self.field.null == False:
+            raise ValueError('Cannot assign None: "%s.%s" does not allow null values.' %
+                                (instance._meta.object_name, self.field.name))
+        elif value is not None and not isinstance(value, self.field.rel.to):
+            raise ValueError('Cannot assign "%r": "%s.%s" must be a "%s" instance.' %
+                                (value, instance._meta.object_name, 
+                                 self.field.name, self.field.rel.to._meta.object_name))
+        
         # Set the value of the related field
         try:
             val = getattr(value, self.field.rel.get_related_field().attname)
@@ -232,11 +243,10 @@ class ReverseSingleRelatedObjectDescriptor(object):
             val = None
         setattr(instance, self.field.attname, val)
 
-        # Clear the cache, if it exists
-        try:
-            delattr(instance, self.field.get_cache_name())
-        except AttributeError:
-            pass
+        # Since we already know what the related object is, seed the related
+        # object cache now, too. This avoids another db hit if you get the 
+        # object you just set.
+        setattr(instance, self.field.get_cache_name(), value)
 
 class ForeignRelatedObjectsDescriptor(object):
     # This class provides the functionality that makes the related-object
diff --git a/tests/regressiontests/many_to_one_regress/models.py b/tests/regressiontests/many_to_one_regress/models.py
index 57bbcd8..012ccbe 100644
--- a/tests/regressiontests/many_to_one_regress/models.py
+++ b/tests/regressiontests/many_to_one_regress/models.py
@@ -25,10 +25,50 @@ class Child(models.Model):
 
 
 __test__ = {'API_TESTS':"""
->>> Third.AddManipulator().save(dict(id='3', name='An example', another=None)) 
+>>> Third.objects.create(id='3', name='An example')
 <Third: Third object>
 >>> parent = Parent(name = 'fred')
 >>> parent.save()
->>> Child.AddManipulator().save(dict(name='bam-bam', parent=parent.id))
+>>> Child.objects.create(name='bam-bam', parent=parent)
 <Child: Child object>
+
+#
+# Tests of ForeignKey assignment and the related-object cache (see #6886)
+#
+>>> p = Parent.objects.create(name="Parent")
+>>> c = Child.objects.create(name="Child", parent=p)
+
+# Look up the object again so that we get a "fresh" object
+>>> c = Child.objects.get(name="Child")
+>>> p = c.parent
+
+# Accessing the related object again returns the exactly same object
+>>> c.parent is p
+True
+
+# But if we kill the cache, we get a new object
+>>> del c._parent_cache
+>>> c.parent is p
+False
+
+# Here's where the changes discussed in #6886 (and committed in [XXXX]) start:
+
+# Assigning a new object results in that object getting cached immediately
+>>> p2 = Parent.objects.create(name="Parent 2")
+>>> c.parent = p2
+>>> c.parent is p2
+True
+
+# Assigning None fails: Child.parent is null=False
+>>> c.parent = None
+Traceback (most recent call last):
+    ...
+ValueError: Cannot assign None: "Child.parent" does not allow null values.
+
+# You also can't assign an object of the wrong type here
+>>> c.parent = First(id=1, second=1)
+Traceback (most recent call last):
+    ...
+ValueError: Cannot assign "<First: First object>": "Child.parent" must be a "Parent" instance.
+
 """}
