hi,

I've got the Category model and SearchForm form shown below. In my
template I'd like to get all Category instances having a given type to
be able to separate those having different style in my CSS.
How can I do this?
thanks
Jul

**Category model***

CATEGORY_TYPE = [
    (1, 'region'),
    (2, 'type'),
]

class Category(models.Model):

    parent = models.ManyToManyField('self', symmetrical=False,
null=True, blank=True)

    type = models.PositiveSmallIntegerField(choices=CATEGORY_TYPE)

    class Translation(multilingual.Translation):
        name = models.CharField(max_length=100, unique=True)

    class Meta:
        verbose_name_plural = 'Categories'

    def __unicode__(self):
        return "%s" %(self.name)


**SearchForm class***

class SearchForm(forms.Form):

    query = forms.CharField(max_length=100, required=False)
    price_range = forms.IntegerField(widget=forms.Select(choices =
PRICE_RANGES_AND_EMPTY), required=False)

    def __init__(self, *args, **kwargs):
        super(SearchForm, self).__init__(*args, **kwargs)
        self.fields['country'] = forms.ModelChoiceField
(queryset=Country.objects.all().order_by('name'), empty_label='All',
required=False)
        self.fields['category'] = forms.ModelMultipleChoiceField
(queryset=Category.objects.all().order_by('name'),
widget=forms.CheckboxSelectMultiple(), required=False)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to