Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#9142 closed (invalid)

Validation shouldn't be coupled with validation...

Reported by: italomaia Owned by: nobody
Component: Forms Version: 1.0-alpha-2
Severity: Keywords: form validation decouple
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Well, very simple. If i have a ModelForm and i want to change a fields widget, i got to do as follows :

class MyForm(forms.ModelForm):
    my_field = forms.SomeField(widget=my_widget)
    class Meta:
        model = my_model

Well, when i do that, part of the form's validation goes away! Let's see a actual example:

class MyModel(models.Model):
    image = models.ImageField(uploat_to="some/path")

class MyForm(forms.ModelForm):
    image = forms.SomeField(widget=SimpleFileWidget)
    class Meta:
        model = MyModel

Well, using MyForm now will not validate if image is actually a image. That seems just wrong, to me.
Something like this would be nicier:

class MyModel(models.Model):
    image = models.ImageField(uploat_to="some/path")

class MyForm(forms.ModelForm):
    image = forms.SomeField(widget=SimpleFileWidget, validation=forms.ImageValidation)
    class Meta:
        model = MyModel

or:
class MyForm(forms.ModelForm):
    image = forms.SomeField(widget=SimpleFileWidget, forms.get_validation(MyModel, "image")) # or something similar.
    class Meta:
        model = MyModel


Change History (2)

comment:1 by italomaia, 16 years ago

Resolution: invalid
Status: newclosed

comment:2 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

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