Yes, What I wanted to do was have a field in my Category model called
num_entries, and every time an Entry model was saved, I wanted to
increment this by one - but I could not work out how to access the
Category model to update just one field per entry (for example if my
entry is in Blog and Django, I want to update each
blog_categories.num_entries field for that row).

Hope that makes sense, as if I can do it this way instead of
calculating it on the view, that would make this inclusion tag so much
easier.

On Dec 5, 2007 3:02 PM, RajeshD <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> >
> > I'm wondering if there is any way possible to get this value in my
> > inclusion tag?
>
> You can use the "extra" method to bring in your entry counts into the
> query set. See the following for an example:
>
> http://www.djangoproject.com/documentation/db-api/#extra-select-none-where-none-params-none-tables-none
>
> > I had tried before to store this value in a field, but
> > couldn't get it to save, otherwise I would just pass in a field
> > 'num_entries' so if anyone can suggest anything, that would be great.
>
> Can you describe what you did that prevented you from saving the
> computed count?
>
> Another solution is to batch compute your counts using a shell script
> at some frequency. The script could iterate over each category and
> recompute its counts and store them.
>
> Yet another solution is to convert your cats queryset to a list, loop
> over it to get an entry count, and then sort the list in Python to
> pass on to your template.
>
> So there seem to be many ways to skin this cat.
>
> -Rajesh Dhawan
> >
>



-- 
Tane Piper
Blog - http://digitalspaghetti.me.uk
AJAX Pastebin - http://pastemonkey.org

This email is: [ ] blogable [ x ] ask first [ ] private

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

Reply via email to