Maniac wrote:
>What happens is that a manipulator checks the values that come from the web, 
>and not the
default ones inside it.

Actually, the manipulator doesn't even know about the default values of
the model.

Your example is based on hidden fields with default values. However,
I've understood that it's considered bad practice [1].

What I ended up with is this quick-and-dirty solution:

    if request.POST:
        new_data = request.POST.copy()
        for field in MyModel._meta.fields:
            if field.name not in new_data.keys():
                if field.default != NOT_PROVIDED:
                    # NOT_PROVIDED imported from
django.core.meta.fields
                    new_data[field.name] = str(field.default)
                else:
                    new_data[field.name] = ''
        new_task_data['mydatetimefield_date'] = ''
        # DateTimeFields must be handled separately
        errors = manipulator.get_validation_errors(new_data)

I'm not sure what kind of trouble I'm putting myself into since the
default values come from Python and go to HTML POST data before
html2python. I guess at least boolean fields need special treatment.

There was discussion about manipulators and default values on the irc
channel yesterday [2]. I also made a ticket on Jacob's request [3].

[1]
http://code.djangoproject.com/wiki/CookBookManipulatorWithHiddenFields
[2] http://simon.bofh.ms/logger/django/2006/01/12/  from 15:10 to 15:21
[3] http://code.djangoproject.com/ticket/1207

Reply via email to