mirror of
https://github.com/django/django.git
synced 2025-10-25 14:46:09 +00:00
Fixed #15185 -- Allowed ModelAdmin.list_display_links=None to disable change list links.
Thanks rm_ for the suggestion.
This commit is contained in:
committed by
Tim Graham
parent
bf757a2f4d
commit
1d0fc61b1c
@@ -7,6 +7,7 @@ from .models import (Event, Child, Parent, Genre, Band, Musician, Group,
|
||||
|
||||
site = admin.AdminSite(name="admin")
|
||||
|
||||
|
||||
class CustomPaginator(Paginator):
|
||||
def __init__(self, queryset, page_size, orphans=0, allow_empty_first_page=True):
|
||||
super(CustomPaginator, self).__init__(queryset, 5, orphans=2,
|
||||
@@ -80,6 +81,7 @@ class DynamicListDisplayChildAdmin(admin.ModelAdmin):
|
||||
my_list_display.remove('parent')
|
||||
return my_list_display
|
||||
|
||||
|
||||
class DynamicListDisplayLinksChildAdmin(admin.ModelAdmin):
|
||||
list_display = ('parent', 'name', 'age')
|
||||
list_display_links = ['parent', 'name']
|
||||
@@ -89,12 +91,20 @@ class DynamicListDisplayLinksChildAdmin(admin.ModelAdmin):
|
||||
|
||||
site.register(Child, DynamicListDisplayChildAdmin)
|
||||
|
||||
|
||||
class NoListDisplayLinksParentAdmin(admin.ModelAdmin):
|
||||
list_display_links = None
|
||||
|
||||
site.register(Parent, NoListDisplayLinksParentAdmin)
|
||||
|
||||
|
||||
class SwallowAdmin(admin.ModelAdmin):
|
||||
actions = None # prevent ['action_checkbox'] + list(list_display)
|
||||
list_display = ('origin', 'load', 'speed')
|
||||
|
||||
site.register(Swallow, SwallowAdmin)
|
||||
|
||||
|
||||
class DynamicListFilterChildAdmin(admin.ModelAdmin):
|
||||
list_filter = ('parent', 'name', 'age')
|
||||
|
||||
@@ -105,6 +115,7 @@ class DynamicListFilterChildAdmin(admin.ModelAdmin):
|
||||
my_list_filter.remove('parent')
|
||||
return my_list_filter
|
||||
|
||||
|
||||
class DynamicSearchFieldsChildAdmin(admin.ModelAdmin):
|
||||
search_fields = ('name',)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user