I am trying to create a manager for a model so that only objects with a status of 0 or 1 show up in the admin.
Could someone please let me know how to write a "where" clause in the manager (e.g "current_status < 2" or something like "current_status=0 or current_status=1") Here's what I tried... #------------------------------------------------- class Repair(models.Model): # some code... class Admin: manager = EditableRepairsManager() #------------------------------------------------- I tried this... #------------------------------------------------- class EditableRepairsManager(models.Manager): def get_query_set(self): from django.db import connection cursor = connection.cursor() cursor.execute(""" SELECT r.id FROM pra_repair r WHERE current_status < 2 ORDER BY r.tail_number """) result_list = [] for row in cursor.fetchall(): id = row[0] repair = Repair.objects.get(pk=id) result_list.append(repair) return result_list #------------------------------------------------- I got this error in the template: AttributeError at /admin/pra/repair/ 'list' object has no attribute 'filter' Request Method: GET Request URL: http://127.0.0.1:8000/admin/pra/repair/ Exception Type: AttributeError Exception Value: 'list' object has no attribute 'filter' I tried this: #------------------------------------------------- class EditableRepairsManager(models.Manager): def get_query_set(self): return super(EditableRepairsManager, self).get_query_set().filter(current_status=0,current_status=1) #------------------------------------------------- I got this error from the dev server terminal window: SyntaxError: duplicate keyword argument I understand why I got the errors but I don't understand how to create the manager I need. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---