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:
Greg Chapple 2014-02-26 22:34:19 +00:00 committed by Tim Graham
parent 6b63742ce5
commit 6acaa52386
5 changed files with 53 additions and 10 deletions

View file

@ -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)