> I know the question is kind of poorly phrased. But here goes, I've been working on a blog software and I want to have five distinct post types (in the same way Tumblr does) but I'm having a hard time figuring out how to create my index view and detail views as they are currently five different models that inherit from the same abstract base model.
>
> Here is my models.py http://dpaste.com/724371/
> as well as my views.py http://dpaste.com/724372/
> and for safe measure, my urls.py within the app http://dpaste.com/724373/
>
> How can I make this work? The current hack of using chain() isn't really working out because of the fact that it returns a list, not a queryset.
It sounds like most of your problems originate from the fact that you're using an abstract base class for posts.
If you make BasePost non-abstract, then you'll be able to generate a queryset of BasePost objects, rather than having to chain through querysets of the concrete subclasses. Once you have a BasePost instance, you can retrieve the specific details associated with each instance with a single attribute request. It also means that when you start introducing links to posts, you won't need to maintain 5 different foreign key types (i.e., link to a text post, link to an image post, etc) -- there's just one "link to a post".
The detail view is also simplified -- it's a detail view for BasePost, not some hybrid that is trying to handle 5 different subclasses.
The only other thing you might want to change is to make post_type a field on BasePost; this isn't strictly required, but it will make it easier to do CORBA-style "narrowing" (i.e., I have a BasePost instance; what type of Post is it, and how do I get an object of that type?).
Hope this helps!
Yours,
Russ Magee %-)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.