Re: Fewer columns in admin popups
On Apr 16, 3:30 pm, andybakwrote: > Is there any other approach to this that could be thread safe? Well, one way would be to cut and paste the entire body of changelist_view from django/contrib/admin/options.py and add some logic around the call to the ChangeList constructor. However, this would mean cutting and pasting 34 lines in order to only change 1, which I was trying to avoid. Another (ugly) option would be monkeypatching the ChangeList constructor. I think it would be nice to be able to define class attributes like popup_list_display, popup_list_display_links, etc. that would override the non-popup attributes for popups if specified. Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Fewer columns in admin popups
On Apr 16, 2:20 pm, Alex Gaynorwrote: > This code isn't threadsafe. If you use your application in a multithreaded > application they will "cross the streams" so to speak and you will see > things rendred with the wrong list display. Ahh, that's what I was afraid of. Thanks for the confirmation. Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Fewer columns in admin popups
On Apr 11, 9:29 am, Dave Benjamin <dave.benja...@gmail.com> wrote: > Is it possible to exclude columns from the popup list view? I may have answered my own question. It looks like the popup is generated from the changelist_view method of ModelAdmin, and this method gets the request as a parameter. I was able to modify the list_display attribute (which seems to be used as an instance attribute even though it normally starts out as a class attribute) before the change list gets generated. However, it seems like the ModelAdmin instance is saved and reused, so I have to code for both the popup and non-popup states, and I wonder if mutating the instance is a thread-safe operation. Anyway, here's what I came up with: class CustomUserAdmin(UserAdmin): # ... def changelist_view(self, request, *args, **kwargs): is_popup = admin.views.main.IS_POPUP_VAR in request.GET if is_popup: self.list_display = [ u'username', u'last_name', u'first_name', u'is_active', u'last_login', ] self.list_display_links = [u'username'] else: self.list_display = [ u'username', u'last_name', u'first_name', u'is_active', u'is_staff', u'date_joined', u'last_login', ] self.list_display_links = [u'username'] return super(CustomUserAdmin, self).changelist_view(request, *args, **kwargs) admin.site.unregister(User) admin.site.register(User, CustomUserAdmin) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Fewer columns in admin popups
Hello, In the Django admin site, I find myself going back and forth between adding more columns to list_display to enhance the list view and then removing them when I realize that they make the list view too big for the popup version displayed when clicking on the add button or the raw_id_fields magnifying glass. I've contemplated making the popup window a little bigger, but I think it would be better if I could just hide certain columns for the popup. That way I could optimize the main list view for a minimum of 1024x768 resolution (and most of my users have wide screens now) but keep the popups smaller than that. Is it possible to exclude columns from the popup list view? Thanks, Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---