Ticket #2684: 2684.patch

File 2684.patch, 1.2 KB (added by russellm, 9 years ago)

Patch to force caching of related objects

  • django/db/models/base.py

     
    9090
    9191    def __init__(self, *args, **kwargs):
    9292        dispatcher.send(signal=signals.pre_init, sender=self.__class__, args=args, kwargs=kwargs)
     93        self._meta._init()       
    9394        for f in self._meta.fields:
    9495            if isinstance(f.rel, ManyToOneRel):
    9596                try:
  • django/db/models/options.py

     
    7474        if not self.db_table:
    7575            self.db_table = "%s_%s" % (self.app_label, self.module_name)
    7676
     77    def _init(self):
     78        "Initialization performed on creation of an object instance."       
     79        # Instantiate the caches of related objects
     80        self.get_all_related_many_to_many_objects()
     81        self.get_all_related_objects()
     82       
    7783    def add_field(self, field):
    7884        # Insert the given field in the order in which it was created, using
    7985        # the "creation_counter" attribute of the field.
Back to Top