Ticket #15146: patch.diff

File patch.diff, 926 bytes (added by elbarto, 14 years ago)
  • django/db/models/fields/related.py

     
    419419
    420420        class RelatedManager(superclass):
    421421            def get_query_set(self):
    422                 db = self._db or router.db_for_read(rel_model, instance=instance)
    423                 return superclass.get_query_set(self).using(db).filter(**(self.core_filters))
     422                if instance.pk is None:
     423                    query = superclass.get_empty_query_set(self)
     424                else:
     425                    db = self._db or router.db_for_read(rel_model, instance=instance)
     426                    query = superclass.get_query_set(self).using(db).filter(**(self.core_filters))
     427                return query
    424428
    425429            def add(self, *objs):
    426430                for obj in objs:
Back to Top