Hi Mario, > I am new in Django. I am implementing a web application using the > django template support. In this way, i am using a single 2-columns > template. While the second column changes according to the presented > content, the first column shows the menu and some statistical > information for all pages. This information must indicate the number > of entities of the model, for example the number of registered users. > > I want to know how show the number of registered users in that page. > Do I need to retrieve this value to each action described in views.py? > The code presented below does not work. > > <h2>Statistics</h2> > <ul> > <li>Users({{User.objects.count}})</li> > ... > </ul>
You could create a custom template tag that renders these statistics for you. See: http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-tags You can then embed this tag in templates where you want to display that info. For added measure, you can add some caching when/if these repetitive DB calls start hurting application performance: http://www.djangoproject.com/documentation/cache/ -Rajesh D --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---