1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #29929 -- Fixed admin view-only change form crash when using ModelAdmin.prepopulated_fields.

This commit is contained in:
Basil Dubyk
2018-11-09 22:41:55 +02:00
committed by Tim Graham
parent 682cdf6cab
commit 7d1123e5ad
4 changed files with 32 additions and 1 deletions

View File

@@ -459,6 +459,13 @@ class PrePopulatedPostAdmin(admin.ModelAdmin):
return self.prepopulated_fields
class PrePopulatedPostReadOnlyAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',)}
def has_change_permission(self, *args, **kwargs):
return False
class PostAdmin(admin.ModelAdmin):
list_display = ['title', 'public']
readonly_fields = (
@@ -1085,6 +1092,7 @@ site2.register(Person, save_as_continue=False)
site7 = admin.AdminSite(name="admin7")
site7.register(Article, ArticleAdmin2)
site7.register(Section)
site7.register(PrePopulatedPost, PrePopulatedPostReadOnlyAdmin)
# Used to test ModelAdmin.sortable_by and get_sortable_by().