To follow up my own post, since I've learned a bit more...
The query set works as expected on an Admin form. What I want to change
is what's shown on the change list Admin page. I'm currently
investigating overriding the change list template and see if I can do it
that way. Any other suggestions are welcome.
On Mon, 2008-02-11 at 11:17 -0500, Adam Stein wrote:
> Using Django v0.96
>
> According to what I've been able to find, I can assign my own Manager to
> a Model. Setting up my default Manager would then affect the default
> query, which includes the one the Admin view would use. For example:
>
> class OrgManager(models.Manager):
> def get_query_set(self):
> qs = super(OrgManager, self).get_query_set()
> return qs.exclude(OR_Name = "N/A")
>
> # Organizations
> class Org(models.Model):
> # Org's name
> OR_Name = models.CharField(
> maxlength = 50,
> help_text = "Name of the organization"
> )
>
> objects = OrgManager()
>
> def __str__(self):
> return self.OR_Name
>
> class Admin:
> pass
>
> The idea it to NOT show the "N/A" entry, but to show all the rest. I
> create OrgManager.get_query_set() to return everything except "N/A". I
> set Org.objects to use this manager, and since it's the only one set, it
> should also be the default. Running in the shell works as expected
> (Org.objects.all() shows all EXCEPT "N/A").
>
> It doesn't look like the Admin view even uses the manager. I even put a
> print statement into get_query_set() to see it being called and it never
> was. Am I missing something? Can I affect the query the Admin view
> uses?
--
Adam Stein @ Xerox Corporation Email: [EMAIL PROTECTED]
Disclaimer: All views expressed
here have been proved to be my own. [http://www.csh.rit.edu/~adam/]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---