Ticket #7904: get_full_query_set.diff
File get_full_query_set.diff, 2.5 KB (added by , 16 years ago) |
---|
-
django/db/models/manager.py
54 54 def get_empty_query_set(self): 55 55 return EmptyQuerySet(self.model) 56 56 57 def get_full_query_set(self): 58 """Returns a new QuerySet object containing all records. Subclasses can 59 override this method to customize queryset instances but it's required 60 that they return all records. 61 """ 62 return QuerySet(self.model) 63 57 64 def get_query_set(self): 58 65 """Returns a new QuerySet object. Subclasses can override this method 59 to easily customize the behavior of the Manager.66 to add custom filters to queryset instances. 60 67 """ 61 return QuerySet(self.model)68 return self.get_full_query_set() 62 69 63 70 def none(self): 64 71 return self.get_empty_query_set() … … 81 88 def get(self, *args, **kwargs): 82 89 return self.get_query_set().get(*args, **kwargs) 83 90 91 def get_full(self, *args, **kwargs): 92 """Used to access parent related objects ensuring that they're 93 not affected by any filters. 94 """ 95 return self.get_full_query_set().get(*args, **kwargs) 96 84 97 def get_or_create(self, **kwargs): 85 98 return self.get_query_set().get_or_create(**kwargs) 86 99 -
django/db/models/fields/related.py
2 2 from django.db.models import signals, get_model 3 3 from django.db.models.fields import AutoField, Field, IntegerField, PositiveIntegerField, PositiveSmallIntegerField, FieldDoesNotExist 4 4 from django.db.models.related import RelatedObject 5 from django.db.models.query import QuerySet6 5 from django.db.models.query_utils import QueryWrapper 7 6 from django.utils.translation import ugettext_lazy, string_concat, ungettext, ugettext as _ 8 7 from django.utils.functional import curry … … 239 238 params = {'%s__pk' % self.field.rel.field_name: val} 240 239 else: 241 240 params = {'%s__exact' % self.field.rel.field_name: val} 242 rel_obj = QuerySet(self.field.rel.to).get(**params)241 rel_obj = self.field.rel.to._default_manager.get_full(**params) 243 242 setattr(instance, cache_name, rel_obj) 244 243 return rel_obj 245 244