Both Bar and Foo obviously have a featured table and are somehow very common 
since you want them to be displayed in on list - which also  makes only sense 
if they share the same attributes cause otherwise you would have empty columns 
depending on the model of the row your are showing.

Maybe Bar and Foo should inherit from a common Model?

To me it seems like your models are not defined well.

Also, to show only items which have featured = True you can use a Filter 
(list_filter) in the admin and not create a special admin.

cheers
Ivo





On Nov 18, 2011, at 15:43 , bax...@gretschpages.com wrote:

>> Can you tell us what you goal here is?
> 
> The goal is to get my combined list of featured items to a changelist
> page. From there, I'll have additional work to do, but step one is
> getting it to the page at all.
> 
> Another thought is to just chain the querysets together and send 'em
> to my own template. It would look like part of the admin, but not
> actually be part of the admin. Problem there, of course, is that if I
> wanted actions, list display, or any other admin-y goodness, I'd be
> out of luck, I think.
> 
> 
>>> I'm trying to combine a subset of two models and pass them to an admin
>>> change list:
>> 
>>> class FeaturedItemsAdmin(admin.ModelAdmin):
>>>   def queryset(self, request):
>>>       qs1 = Foo.objects.filter(featured=True)
>>>       qs2 = Bar.objects.filter(featured=True)
>>>      ..... do stuff to combine ...
>>>      return combined
>> 
>>> I can return qs1 or qs2 to the admin, no problem. But I can't put them
>>> together in a way the admin will accept.
>> 
>>> First thing I tried was a simple itertools.chain. I've also tried
>>> building a custom queryset (http://djangosnippets.org/snippets/1933/)
>>> and subclassing queryset. At best, I get nothing, but most times I
>>> get:
>> 
>>> "Database error
>>> Something's wrong with your database installation. Make sure the
>>> appropriate database tables have been created, and make sure the
>>> database is readable by the appropriate user."
>> 
>>> Which I've tracked down to a IncorrectLookupParameters exception in
>>> contrib.admin.options, but that doesn't really help me figure out what
>>> it is the admin wants that I'm not giving 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-users@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group 
>>> athttp://groups.google.com/group/django-users?hl=en.
> 
> -- 
> 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 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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