Hello!
Before I wrote this e-mail, I look at the tickets but I haven't found
none with this approach.
I have this models:
<code>
class ArticleManager(models.Manager):
def get_query_set(self):
return super(ArticleManager, self).get_query_set().extra(
select={'comments_count': 'select count(*) from comments
where comments.article_id = article.id'}
)
class Article(models.Model):
# Fields must be here
objects = ArticleManager() # Overriding the `models.Manager`
</code>
I wanted that extra field "comments_count" have sort and filter
functions on Admin Site. Then I modify the
"contrib.admin.templatetags.admin_list.py" and
"contrib.admin.views.main.py" files to do it. This way I can create
"calculated fields" with sort and filter facilities on Admin Site,
that it's very useful for me to manage status for many models (for
example: "late" or "due soon" would be values for the calculated field
status)
My question: There is an easier/another way to do this?
Thanks.
--
Túlio de Paiva
[EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---