def clean_name(self):
    name = self.cleaned_data['name']
    try:
        voucher = Voucher.objects.get(name=name)
    except Voucher.DoesNotExist:
        pass
    else:
        if ((not self.voucher) or (voucher.id != self.voucher.id)):
            raise forms.ValidationError((_("The name '%s' is already in use") % name))
    return name
def clean_name(self):
    name = self.cleaned_data['name']
    try:
        voucher = Voucher.objects.get(name=name)
    except Voucher.DoesNotExist:
        pass
    else:
        if ((not self.voucher) or (voucher.id != self.voucher.id)):
            raise forms.ValidationError((_("The name '%s' is already in use") % name))
    return name