mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #29929 -- Fixed admin view-only change form crash when using ModelAdmin.prepopulated_fields.
This commit is contained in:
parent
682cdf6cab
commit
7d1123e5ad
4 changed files with 32 additions and 1 deletions
|
@ -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().
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue