On 06/13/2012 06:12 PM, Doug Blank wrote:
> On Wed, Jun 13, 2012 at 5:05 PM, Carl Meyer <[email protected]> wrote:
>> On 06/13/2012 02:55 PM, Peter wrote:
>>> Can I throw in option 5:
>>>
>>> We leave ModelForms as they are, but emit a warning if you only
>>> partially render the form?
>>>
>>> I'm not sure how feasible this is, but presumably we could keep track of
>>> which fields have been rendered for a given form instance?
>>>
>>> That way, if you render the whole form ( {{ form.as_p }} ) you'll see
>>> your new sensitive field appear in the page. If you manually render the
>>> form, you'll get a warning.
>>
>> I've thought about this. The main problem is that the implementation is
>> quite difficult in practice: at what point do you perform the check?
>> There isn't any such thing as an "ok, I think I'm all done rendering
>> this form now, tell me if I did it right" hook.
> 
> I, too, was thinking about this kind of solution. In fact, it came up
> for me the other day because I had forgotten to exclude a field that I
> did not have on the form, and so the value ended up getting wiped out
> when I saved. So, perhaps a solution that prevented others from adding
> fields could also be a solution that checked to make sure that the
> form was editing all fields it should be.
> 
> What about a {% validate %} tag in the form which would do a runtime
> check to make sure that all non-excluded fields had been rendered?

Yeah, this would be a cleaner way to implement the check. I'd like to
see it proved out as a third-party add-on before discussing it for core.
One of the unresolved issues in my mind is what it should actually _do_
if you haven't rendered all the fields on the form (blow up in DEBUG
mode only? Just a call to warnings.warn?).

And since it's opt-in (and easy to forget or not bother with) I'm not
sure that by itself it's a satisfactory solution to the original problem
of implicit Meta.fields.

Carl

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to