Commits

Matthew Schinckel committed 1b4e3a0

Handle if the value is already an object, or if it is an id.

Comments (0)

Files changed (1)

rest_api/options.py

                     # Do I need to serialize this?
                     if field.rel:
                         if value is not None:
-                            rel_obj = field.rel.to.objects.get(pk=value)
+                            if isinstance(value, field.rel.to):
+                                rel_obj = value
+                            else:
+                                rel_obj = field.rel.to.objects.get(pk=value)
                         else:
                             rel_obj = None
                         setattr(instance, key, rel_obj)