Malcolm,
thanks for taking the time to clarify the concept for me. I can see
now that Django's approach is valid if one takes a form as a
specification of what "has to be there" (hence the exclude mechanism
in ModelForms) and not, as I did, of what "could be submitted". I
still have a vague feeli
On Fri, 2009-01-09 at 00:59 -0800, Flo Ledermann wrote:
> Malcolm,
>
> As a relatively new Django user but experienced web developer I just
> found it counter-intuitive that the Form would set fields that are
> nowhere specified or even mentioned in the request. To follow your
> line of thought,
On Fri, Jan 9, 2009 at 9:59 AM, Flo Ledermann
wrote:
>> No. Don't ask the form class to read your mind. Create a form that knows
>> which fields it expects so that errors can be raised correctly and
>> validation will occur normally.
>
> I am not asking the form class to read my mind but to read
Malcolm,
As a relatively new Django user but experienced web developer I just
found it counter-intuitive that the Form would set fields that are
nowhere specified or even mentioned in the request. To follow your
line of thought, a validation error should be raised if a required
field is not prese
Karen,
On Jan 9, 12:40 am, "Karen Tracey" wrote:
> Is there some reason you are not simply using exclude in Meta for the form
> to avoid having these fields present in the form at all:
this would require me to create ModelForm classes for all subsets of
the form I want to use. In my use case I
On Thu, 2009-01-08 at 07:08 -0800, Flo Ledermann wrote:
> Hi all,
>
> I am trying to use a ModelForm in a "sparse" way to edit instances,
> i.e. I only render one of its fields (plus a submit button) in the
> template for editing the corresponding field in the model. I would
> have expected that
On Thu, Jan 8, 2009 at 11:34 AM, Flo Ledermann
wrote:
>
> Hi all,
>
> after some more thinking, the workaround I came up with is now:
>
> if form.is_valid():
>for key in form.cleaned_data.keys():
>if not key in request.POST: del form.cleaned_data[key]
>form.save()
>
> This removes
Hi all,
after some more thinking, the workaround I came up with is now:
if form.is_valid():
for key in form.cleaned_data.keys():
if not key in request.POST: del form.cleaned_data[key]
form.save()
This removes all values that are not found in the original request
from the form da
Hi all,
I am trying to use a ModelForm in a "sparse" way to edit instances,
i.e. I only render one of its fields (plus a submit button) in the
template for editing the corresponding field in the model. I would
have expected that fields not present in the POST data of the request
would be omitted
9 matches
Mail list logo