Re: newforms and models unique=True validation

2007-07-19 Thread stereoit
+1 it works, perfect (I just change the self.cleaned_data into self.clean_data). Now when you showed me the trick I was able to track it in docs as well, unfortunately I'm using 0.96 and http://www.djangoproject.com/documentation/0.96/newforms/ is much different to http://www.djangoproject.com/doc

Re: newforms and models unique=True validation

2007-07-18 Thread Nathan Ostgard
You can create a BaseForm class and specify it in your form_for_model call: from django import newforms as forms class MyBaseForm(forms.BaseForm): def clean_myfield(self): if MyModel.objects.filter(myfield=self.cleaned_data['myfield']).count(): raise forms.ValidationError('some error

Re: newforms and models unique=True validation

2007-07-18 Thread Nathan Ostgard
You want to create a BaseForm to specify in your form_for_model call. You could do something like: from django import newforms as forms class MyBaseForm(forms.BaseForm): def clean_myfield(self): if MyModel.objects.filter(myfield=self.cleaned_data['myfield']).count(): raise forms.Vali

newforms and models unique=True validation

2007-07-18 Thread stereoit
Hi, I have model with field that has attribute unique set to True. I know newforms are not able to handle such a validation as this is DB related. However I read at newforms doc page that it is possible to provide method called clean_() that can do custom validation. My problem is that method is s