From 45cbd8bc606cfe8c100aac6f46872261d1d127c3 Mon Sep 17 00:00:00 2001 From: mtredinnick Date: Fri, 14 Sep 2007 01:45:26 +0000 Subject: [PATCH] Fixed #3922 -- Added a warning that fields passed to form_for_model callback function should not be modified. It's bad for your health. Thanks, Philippe Raoult. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6148 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- AUTHORS | 1 + docs/newforms.txt | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/AUTHORS b/AUTHORS index babe9359..43ec7ded 100644 --- a/AUTHORS +++ b/AUTHORS @@ -241,6 +241,7 @@ answer newbie questions, and generally made Django that much better: Jan Rademaker Michael Radziej Amit Ramon + Philippe Raoult Massimiliano Ravelli Brian Ray remco@diji.biz diff --git a/docs/newforms.txt b/docs/newforms.txt index 33625f39..10fa15a1 100644 --- a/docs/newforms.txt +++ b/docs/newforms.txt @@ -1916,6 +1916,17 @@ Note that your callback needs to handle *all* possible model field types, not just the ones that you want to behave differently to the default. That's why this example has an ``else`` clause that implements the default behavior. +.. warning:: + The field that is passed into the ``formfield_callback`` function in + ``form_for_model()`` and ``form_for_instance`` is the field instance from + your model's class. You **must not** alter that object at all; treat it + as read-only! + + If you make any alterations to that object, it will affect any future + users of the model class, because you will have changed the field object + used to construct the class. This is almost certainly what you don't want + to have happen. + Finding the model associated with a form ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 2.11.4.GIT