Re: How to get comment_count in view?

2008-11-12 Thread David.D

Thank you. It worked.

On 11月2日, 下午6时11分, "Chatchai Neanudorn" <[EMAIL PROTECTED]> wrote:
> from django.contrib.comments.models import Comment
> from post.models import Post
>
> #get comments for model
> Comment.objects.for_model(Post).count()
>
> #get comment for instance
> Comment.objects.for_model(Post.objects.get(id=1)).count()
>
> 2008/11/2 David.D <[EMAIL PROTECTED]>
>
>
>
> > I can get comment_count in templates:
>
> > {% get_comment_count for object as comment_count %}
>
> > But how to get it in my view?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get comment_count in view?

2008-11-04 Thread Info Cascade

I was just asking myself a similar question. I want to know the total
result count of a query but only return  a subset of the query.
Articles.objects.filter(somefield__contains='some
query')[start:start+num_rows]

I understand the slice creates a LIMIT in the database query.  But I
also need the total non-limited result count, which could potentially be
quite large.  It seems wasteful to get the entire query result and then
use .count() or len() to get the number of rows returned, and *then*
slice it anyway.

What is the best approach?

In MySQL it's possible to do
select SQL_CALC_FOUND_ROWS  * from table limit 5,10
Then, you can do "select FOUND_ROWS()"

Has anyone tried something similar?  I'm now using Postgres, which I
assume has some similar functionality. Anyone know what it is?

Any comments welcome.

Best,
Liam



Chatchai Neanudorn wrote:
> from django.contrib.comments.models import Comment
> from post.models import Post
>
> #get comments for model
> Comment.objects.for_model(Post).count()
>
> #get comment for instance
> Comment.objects.for_model(Post.objects.get(id=1)).count()
>
> 2008/11/2 David.D <[EMAIL PROTECTED]
> >
>
>
> I can get comment_count in templates:
>
> {% get_comment_count for object as comment_count %}
>
>
> But how to get it in my view?
>
>
>
> >


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get comment_count in view?

2008-11-02 Thread Chatchai Neanudorn
from django.contrib.comments.models import Comment
from post.models import Post

#get comments for model
Comment.objects.for_model(Post).count()

#get comment for instance
Comment.objects.for_model(Post.objects.get(id=1)).count()

2008/11/2 David.D <[EMAIL PROTECTED]>

>
> I can get comment_count in templates:
>
> {% get_comment_count for object as comment_count %}
>
>
> But how to get it in my view?
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to get comment_count in view?

2008-11-01 Thread David.D

I can get comment_count in templates:

{% get_comment_count for object as comment_count %}


But how to get it in my view?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---