Ticket #11448: clear_related_cache.diff
File clear_related_cache.diff, 1.5 KB (added by , 15 years ago) |
---|
-
django/db/models/fields/related.py
743 743 cls._meta.duplicate_targets[self.column] = (target, "o2m") 744 744 745 745 def contribute_to_related_class(self, cls, related): 746 try: 747 del(cls._meta._related_objects_cache) 748 except AttributeError: 749 pass 746 750 setattr(cls, related.get_accessor_name(), ForeignRelatedObjectsDescriptor(related)) 747 751 748 752 def formfield(self, **kwargs): … … 782 786 super(OneToOneField, self).__init__(to, to_field, OneToOneRel, **kwargs) 783 787 784 788 def contribute_to_related_class(self, cls, related): 789 try: 790 del(cls._meta._related_objects_cache) 791 except AttributeError: 792 pass 785 793 setattr(cls, related.get_accessor_name(), 786 794 SingleRelatedObjectDescriptor(related)) 787 795 … … 948 956 def contribute_to_related_class(self, cls, related): 949 957 # m2m relations to self do not have a ManyRelatedObjectsDescriptor, 950 958 # as it would be redundant - unless the field is non-symmetrical. 959 try: 960 del(cls._meta._related_many_to_many_cache) 961 except AttributeError: 962 pass 951 963 if related.model != related.parent_model or not self.rel.symmetrical: 952 964 # Add the descriptor for the m2m relation 953 965 setattr(cls, related.get_accessor_name(), ManyRelatedObjectsDescriptor(related))