Ticket #5372: caching-of-sql-queries.diff

File caching-of-sql-queries.diff, 694 bytes (added by Petr Marhoun <petr.marhoun@…>, 17 years ago)
  • django/contrib/admin/options.py

    === modified file 'django/contrib/admin/options.py'
     
    665665        self.parent_model = parent_model
    666666        self.opts = self.model._meta
    667667        super(InlineModelAdmin, self).__init__()
     668       
     669    def formfield_for_dbfield(self, db_field, **kwargs):
     670        if isinstance(db_field, models.ForeignKey):
     671            kwargs['cache_choices'] = True
     672        return super(InlineModelAdmin, self).formfield_for_dbfield(db_field, **kwargs)
    668673
    669674    def formset_add(self, request):
    670675        """Returns an InlineFormSet class for use in admin add views."""
Back to Top