managers or classmethods?

2010-02-24 Thread HARRY POTTRER
Why not something like this: class Person(models.Model): @classmethod def male(cls): return cls.objects.filter(gender='M') @classmethod def female(cls): return cls.objects.filter(gender='F') name = models.CharField(maxlength=20) gender = models.CharField(m

displaying validation errors

2010-02-24 Thread jimgardener
hello guys, I wanted to display validation errors in the form .I tried this class BookForm(ModelForm): class Meta: model=Book def clean_bookname(self): bkname=self.cleaned_data['bookname'] bkname=bkname.strip() if Book.objects.filter(bookname__iexact=bkname)

Re: Template Form Field Styles

2010-02-24 Thread jbergantine
Yeah, no problem. This is a snippet I've used before. If there aren't errors it just wraps a div around the label and input element. If there are errors it appends a class of 'error' to the div. {% for field in form %} {% if field.errors %} {% else %} {% endif %} {% if field.fiel

Can't explain this ImportError

2010-02-24 Thread Adam Yee
Just started using haystack. I've created an extended search form of SearchForm and have it located at /mysite/search/search_forms.py The import error happens in haystack.urls Traceback: File "/home/adam/stldata-djangosvn-2.6/lib/python2.6/site-packages/ django/core/handlers/base.py" in get_resp

<    1   2