SHARE
TWEET

Untitled

a guest Feb 18th, 2011 151 Never
  1. # the view code
  2. def company_list(request):
  3.     qs = Company.objects.all()
  4.  
  5.     # custom filter using django-filters
  6.     f = CompanyFilter(request.GET, queryset=qs)
  7.  
  8.     return object_list(request,
  9.                        extra_context={'filter': f},
  10.                        queryset=f.qs.distinct(),
  11.                        template_name='supplier/company/list.html',
  12.                        template_object_name='company',
  13.                        paginate_by=30)
  14.  
  15.  
  16.  
  17. # part of the model code
  18.  
  19. class Company(models.Model):
  20.     regions = models.ManyToManyField(Region, blank=True, null=True)
  21.     categories = models.ManyToManyField(Category, blank=True, null=True)
RAW Paste Data
Top