Opened 8 years ago
Last modified 2 years ago
#28068 new New feature
Allow customizing popup window for selecting related objects in django admin
Reported by: | Artem Skoretskiy | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | tonn81@… | Triage Stage: | Someday/Maybe |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In Django admin when you select related object in Django admin -- it shows you popup window. Size of this popup is hardcoded to 800x500 px and does not always match user expectations. It would be great to allow changing it at least system-wide.
Proposal:
- Provide a setting to change default popup size
- Use some global Javascript variable for storing popup size so we could override per page
Sample application:
# models.py class Author(models.Model): name = models.CharField(max_length=100) class Book(models.Model): author = models.ForeignKey(Author) name = models.CharField(max_length=100) # admin.py @admin.register(Author) class AuthorAdmin(admin.ModelAdmin): pass @admin.register(Book) class BookAdmin(admin.ModelAdmin): raw_id_fields = ('author',)
Source code:
// RelatedObjectLookups.js function showAdminPopup(triggeringLink, name_regexp, add_popup) { var name = triggeringLink.id.replace(name_regexp, ''); name = id_to_windowname(name); var href = triggeringLink.href; if (add_popup) { if (href.indexOf('?') === -1) { href += '?_popup=1'; } else { href += '&_popup=1'; } } var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes'); win.focus(); return false; } //-----------------------------------------^ here it is
Change History (5)
comment:1 by , 8 years ago
comment:2 by , 8 years ago
Could you elaborate on "does not always match user expectations"? Maybe it makes sense to change the default since monitor resolution has increased over the years. I'm not sure if adding a setting for this is really needed.
comment:3 by , 8 years ago
Users expect something bigger than 800x500. It is hard to suggest a single resolution for everyone -- some users have 1280x768, others have 1920x1080 monitors.
Another alternative is to calculate popup size in runtime by JavaScript according to user screen size. We could reuse parts of my workaround (it generates 2/3 of size of source window or screen).
comment:4 by , 8 years ago
Triage Stage: | Unreviewed → Someday/Maybe |
---|
Maybe you could raise the idea on the DevelopersMailingList and ask for ideas.
comment:5 by , 2 years ago
Pretty simple is also to leave the browser to open it in new tab. Full size of the browser is usually good sizing in admin as the user is not taken out of context by popup.
var win = window.open(href, name);
It is the workaround I had to add via base.html (does not work well with Firefox and not smooth):