diff options
| author | Greg Chapple <gregchapple1@gmail.com> | 2014-02-26 22:34:19 +0000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-03-03 07:28:24 -0500 |
| commit | 6acaa5238668593d6d854b28dbfa65e95796585c (patch) | |
| tree | 1c431b7ad63553a473834a4c555be7358f5c5fc2 /docs | |
| parent | 6b63742ce5a63484890f147830d3fa9b2d0342f9 (diff) | |
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.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/contrib/admin/index.txt | 15 | ||||
| -rw-r--r-- | docs/releases/1.7.txt | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index 2c852a3ee4..f2fdd39714 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -1709,6 +1709,21 @@ templates used by the :class:`ModelAdmin` views: ``obj_display`` is a string with the name of the deleted object. +.. method:: ModelAdmin.get_changeform_initial_data(request) + + .. versionadded:: 1.7 + + A hook for the initial data on admin change forms. By default, fields are + given initial values from ``GET`` parameters. For instance, + ``?name=initial_value`` will set the ``name`` field's initial value to be + ``initial_value``. + + This method should return a dictionary in the form + ``{'fieldname': 'fieldval'}``:: + + def get_changeform_initial_data(self, request): + return {'name': 'custom_initial_value'} + Other methods ~~~~~~~~~~~~~ diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index f9400032e5..305cf6da66 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -308,6 +308,10 @@ Minor features <django.contrib.admin.ModelAdmin.list_display>` value by prefixing the ``admin_order_field`` value with a hyphen. +* The :meth:`ModelAdmin.get_changeform_initial_data() + <django.contrib.admin.ModelAdmin.get_changeform_initial_data>` method may be + overridden to define custom behavior for setting initial change form data. + :mod:`django.contrib.auth` ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
