mirror of
https://github.com/django/django.git
synced 2025-08-11 14:28:54 +00:00
Fixed #22135 -- Added ModelAdmin.get_changeform_initial_data().
Allows custom behavior for setting initial form data in ModelAdmin. By default, initial data is set via GET params. The new method allows this behavior to be overridden. Thanks egasimus for the suggestion.
This commit is contained in:
parent
6b63742ce5
commit
6acaa52386
5 changed files with 53 additions and 10 deletions
|
@ -796,6 +796,10 @@ class RestaurantAdmin(admin.ModelAdmin):
|
|||
inlines = [WorkerInlineAdmin]
|
||||
view_on_site = False
|
||||
|
||||
def get_changeform_initial_data(self, request):
|
||||
return {'name': 'overridden_value'}
|
||||
|
||||
|
||||
site = admin.AdminSite(name="admin")
|
||||
site.register(Article, ArticleAdmin)
|
||||
site.register(CustomArticle, CustomArticleAdmin)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue