Opened 19 years ago

Last modified 18 years ago

#275 closed defect

Missing arg in django.core.validators.RequiredIfOtherFieldGiven introduced by changeset 403 — at Version 2

Reported by: jhernandez Owned by: Adrian Holovaty
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Adrian Holovaty)

in line 240 of django/core/validators.py the get() method is invoked with less arguments than the required:

In method call of class RequiredIfOtherFieldsGiven :

def __call__(self, field_data, all_data):
    for field in self.other:
        if all_data.get(field) and not field_data:
           raise ValidationError, self.error_message

looking at the call method of the class RequiredIfOtherFieldNotGiven, the get() method is invoked in this way:

if not all_data.get(self.other, False) and not field_data:

maybe the missed argument is just False, but I'm not sure :-(

This breaks the edit_inline example in tutorial02.

This is the traceback generated when you call "save" on the add poll form:

There's been an error:

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/django/core/handlers/base.py", line 63, in get_response
    return callback(request, **param_dict)

  File "/usr/lib/python2.3/site-packages/django/views/admin/main.py", line 765, in add_stage
    errors = manipulator.get_validation_errors(new_data)

  File "/usr/lib/python2.3/site-packages/django/core/formfields.py", line 70, in get_validation_errors
    validator(new_data.get(field.field_name, ''), new_data)

  File "/usr/lib/python2.3/site-packages/django/core/validators.py", line 240, in __call__
    if all_data.get(field) and not field_data:

TypeError: get() takes exactly 3 arguments (2 given)

Change History (2)

comment:1 by jhernandez, 19 years ago

Component: Admin interfaceCore framework

I selected the wrong component, not to metion the missing formating, next time I'll do better.

comment:2 by Adrian Holovaty, 19 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top