Date Tags Django

DJANGO: fields order in ModelForm and clean

Imagine that we wants to clean field image differently in dependence of value of type.

class MyImageForm(forms.ModelForm):
    class Meta:
        model = MyImage
        fields = ('image', 'type', 'image_url')

in this case from clean_image method we can't get self.cleaned_data['type']. But if we change order :

fields = ( 'type', 'image', 'image_url')

In this case type will be available in self.cleaned_data['type'] and we can validate in dependence of it's value.
So in my case it works. (django 1.2)
But in docs I can't found any information about it only by sources. Fields order influence not only render order but and clean.


Comments

comments powered by Disqus