Ticket #17881: 17881-poc.patch

File 17881-poc.patch, 2.0 KB (added by aaugustin, 3 years ago)
  • django/contrib/admin/options.py

     
    112112            # extra HTML -- the "add other" interface -- to the end of the
    113113            # rendered output. formfield can be None if it came from a
    114114            # OneToOneField with parent_link=True or a M2M intermediary.
    115             if formfield and db_field.name not in self.raw_id_fields:
     115            if formfield and db_field.name not in self.get_raw_id_fields(request):
    116116                related_modeladmin = self.admin_site._registry.get(
    117117                                                            db_field.rel.to)
    118118                can_add_related = bool(related_modeladmin and
     
    156156        Get a form Field for a ForeignKey.
    157157        """
    158158        db = kwargs.get('using')
    159         if db_field.name in self.raw_id_fields:
     159        if db_field.name in self.get_raw_id_fields(request):
    160160            kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.rel,
    161161                                    self.admin_site, using=db)
    162162        elif db_field.name in self.radio_fields:
     
    177177            return None
    178178        db = kwargs.get('using')
    179179
    180         if db_field.name in self.raw_id_fields:
     180        if db_field.name in self.get_raw_id_fields(request):
    181181            kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel,
    182182                                    self.admin_site, using=db)
    183183            kwargs['help_text'] = ''
     
    200200        """
    201201        return self.ordering or ()  # otherwise we might try to *None, which is bad ;)
    202202
     203    def get_raw_id_fields(self, request):
     204        """
     205        Hook for specifying custom raw id fields.
     206        """
     207        return self.raw_id_fields
     208
    203209    def get_readonly_fields(self, request, obj=None):
    204210        """
    205211        Hook for specifying custom readonly fields.
Back to Top