Ticket #17547: django-baseadmin-addlink-optional.patch
File django-baseadmin-addlink-optional.patch, 1.2 KB (added by , 13 years ago) |
---|
-
contrib/admin/options.py
78 78 overrides.update(self.formfield_overrides) 79 79 self.formfield_overrides = overrides 80 80 81 def formfield_for_dbfield(self, db_field, **kwargs):81 def formfield_for_dbfield(self, db_field, can_add_related=True, **kwargs): 82 82 """ 83 83 Hook for specifying the form Field instance for a given database Field 84 84 instance. … … 111 111 # extra HTML -- the "add other" interface -- to the end of the 112 112 # rendered output. formfield can be None if it came from a 113 113 # OneToOneField with parent_link=True or a M2M intermediary. 114 if formfield and db_field.name not in self.raw_id_fields: 114 if (can_add_related and formfield and 115 db_field.name not in self.raw_id_fields): 115 116 related_modeladmin = self.admin_site._registry.get( 116 117 db_field.rel.to) 117 118 can_add_related = bool(related_modeladmin and