#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 , 17 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
comment:2 by , 17 years ago
| milestone: | post-1.0 |
|---|
Note:
See TracTickets
for help on using tickets.
Milestone post-1.0 deleted