

def clean_code(self):
    code = self.cleaned_data.get('code')
    if (not code):
        return self.cleaned_data
    try:
        discount = code.discount_model.objects.get(code=code)
    except self.discount_model.DoesNotExist:
        raise forms.ValidationError(_('This code does not validate'))
    discount.validate(self.order)
    self.cleaned_data['discount'] = discount
    return code

dataset/ETHPy150Open matthiask/plata/plata/shop/forms.py DiscountForm.clean_code/VarMisuse@41/50 `self`->`code`