=== modified file 'django/contrib/admin/options.py'
|
|
|
661 | 661 | self.parent_model = parent_model |
662 | 662 | self.opts = self.model._meta |
663 | 663 | # TODO: pass a fields arg into forms.inline_formset if/when we have one |
664 | | self.formset_class = forms.inline_formset(parent_model, self.model, fk_name=self.fk_name, formfield_callback=self.formfield_for_dbfield, extra=self.extra) |
| 664 | |
| 665 | def formfield_for_dbfield(self, db_field, **kwargs): |
| 666 | if isinstance(db_field, models.ForeignKey): |
| 667 | kwargs['cache_choices'] = True |
| 668 | return super(InlineModelAdmin, self).formfield_for_dbfield(db_field, **kwargs) |
| 669 | |
| 670 | def _formset_class(self): |
| 671 | return forms.inline_formset(self.parent_model, self.model, fk_name=self.fk_name, formfield_callback=self.formfield_for_dbfield, extra=self.extra) |
| 672 | formset_class = property(_formset_class) |
665 | 673 | |
666 | 674 | def fieldsets(self, request): |
667 | 675 | """ |