That's it! thanks!

On Mar 27, 1:56 am, Dennis Kaarsemaker <den...@kaarsemaker.net> wrote:
> On vr, 2010-03-26 at 17:21 -0700, david.schruth wrote:
>
> > I'm wondering if there is an easy way to set up a default filter on
> > the rows of my table:
>
> > 1) at all
>
> Yes.
>
> > 2) using a foreign class' field
>
> Yes.
>
> > for example.
>
> > lets say I have a table called
> >    'student' with fields name, gpa, school, etc
> >  and another called
> >     'school' with fields name, closed
>
> > in the case of question 1)
> > what if I wanted to just show the students with gpa > 3.0 in the admin
> > interface?
>
> class StudentAdmin(admin.ModelAdmin):
>     def queryset(self, request):
>         return super(StudentAdmin,self).queryset(request).filter(gpa__gt=3.0)
>
> > in the case of question 2)
> > what if I just wanted to show the students who's school is not closed?
>
> class StudentAdmin(admin.ModelAdmin):
>     def queryset(self, request):
>         return 
> super(StudentAdmin,self).queryset(request).filter(school__closed=False)
>
> --
> Dennis K.
>
> The universe tends towards maximum irony. Don't push it.

-- 
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