Anders
unread,Oct 7, 2014, 7:15:21 PM10/7/14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hello,
I am looking for some feedback on a seemingly simple problem.
My advertisement board project have 10+ models, one model per item
category (Cars, Pets, Apartments and so on). The common fields (title,
seller, location etc.) is defined in "MyAbstractModel" and inherited by
all other category models.
So far so good until it comes to rendering the items on the front-page
template.
Right now I just have 10+ blocks with for-loops in the template, listing
the 5 latest items in each category.
But I want to the user to be able to specify the order of categories in
the front page, and also which ones of the categories that should be
shown/hidden.
And that is where I am lost.
I guess I could have a "profile"-model which specifies the order and
visibility for each category, and a decent query filter and order_by
should do the trick I think.
But for the template I do not know, as the properties are different for
each category.
Maybe with a for-tag iterating the object list, and if there is a way to
figure out exactly what type of object it is use some if-tags display
the correct category properties maybe?
Any advice is welcome, and please feel free to ask if it seems unclear
(my thinking sometimes is hard to explain in words).
-A