Opened 5 years ago

Closed 5 years ago

#16542 closed Bug (fixed)

Admin Raw ID widgets can show broken magnifying glass link

Reported by: Ramiro Morales Owned by: Ramiro Morales
Component: contrib.admin Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ramiro Morales)

This can happen when the related model isn't registered with the same admin site.

Ideally these widgets should behave in a way consistent with the regular non-raw ID admin widgets in this regard.

Example:

# models.py

from django.db import models

class Honeycomb(models.Model):
    location = models.CharField(max_length=20)

class Bee(models.Model):
    honeycomb = models.ForeignKey(Honeycomb)
# admin.py

from django.contrib import admin

import models

class BeeAdmin(admin.ModelAdmin):                                                                                                                                            
    raw_id_fields = ('honeycomb',) 

admin.site.register(models.Bee)

Try to add a Bee instance, in the add view click in the magnifying glass besides the 'Honeycomb' field, this leads to a 404 error.

Attachments (1)

16542.2.diff (20.5 KB) - added by Ramiro Morales 5 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 5 years ago by Ramiro Morales

Description: modified (diff)
Owner: changed from nobody to Ramiro Morales

Changed 5 years ago by Ramiro Morales

Attachment: 16542.2.diff added

comment:2 Changed 5 years ago by Ramiro Morales

Has patch: set

comment:3 Changed 5 years ago by Aymeric Augustin

Triage Stage: UnreviewedAccepted

comment:4 Changed 5 years ago by anonymous

I see no reason for

except NoReverseMatch: 
    raise 

Aside from that it looks good I guess ;)

comment:5 in reply to:  4 Changed 5 years ago by Ramiro Morales

Replying to anonymous:

I see no reason for

except NoReverseMatch: 
    raise 

Aside from that it looks good I guess ;)

Point taken. Thanks

comment:6 Changed 5 years ago by Ramiro Morales

Resolution: fixed
Status: newclosed

In [16578]:

Fixed #16542 -- Made Raw ID form widgets shipped with the admin app render the related object lookup tool only when the related model is effectively registered with the AdminSite.

Also, converted these widgets to reverse named URLs instead of hard-coded '../../...'-style links, refs #15294.
Thanks Florian Apolloner for the initial patch.

Note: See TracTickets for help on using tickets.
Back to Top