Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 18th, 2011  |  syntax: Python  |  size: 0.66 KB  |  views: 137  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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)
clone this paste RAW Paste Data