Ticket #15494: only_pk_related.diff
File only_pk_related.diff, 846 bytes (added by , 14 years ago) |
---|
-
django/db/models/query.py
708 708 # Can only pass None to defer(), not only(), as the rest option. 709 709 # That won't stop people trying to do this, so let's be explicit. 710 710 raise TypeError("Cannot pass None as an argument to only().") 711 712 cleaned_fields = [] 713 for field_name in fields: 714 if field_name == 'pk': 715 field_name = self.model._meta.pk.name 716 cleaned_fields.append(field_name) 717 711 718 clone = self._clone() 712 clone.query.add_immediate_loading( fields)719 clone.query.add_immediate_loading(cleaned_fields) 713 720 return clone 714 721 715 722 def using(self, alias):