+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
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
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
3 matches
Mail list logo