Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#275 closed defect (fixed)

Missing arg in django.core.validators.RequiredIfOtherFieldGiven introduced by changeset 403

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: UI/UX:

Description (last modified by Adrian Holovaty)

in line 240 of django/core/ 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/", line 63, in get_response
    return callback(request, **param_dict)

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

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

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

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

Change History (3)

comment:1 Changed 13 years ago by jhernandez

Component: Admin interfaceCore framework

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

comment:2 Changed 13 years ago by Adrian Holovaty

Description: modified (diff)

comment:3 Changed 13 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [410]) Fixed #275 -- Bug in validators.RequiredIfOtherFieldsGiven. Thanks, jhernandez

Note: See TracTickets for help on using tickets.
Back to Top