Hi Julian,

On Wed, 2006-10-04 at 01:54 -0700, [EMAIL PROTECTED] wrote:
> Hi,
> 
> I recently started using Django.  I'm still getting a bit confused with
> the interaction between the Views and the Template.  I understand or
> figure that pretty much all the data processing should be handled
> within the View.
> 
> I'm using render_to_response sort of like this:
> ----
> from django.shortcuts import get_object_or_404, render_to_response
> from my_site.property.models import Data
> 
> def index(request):
>     object_list = Data.objects.filter(job =
> "Accountant").order_by('-salary')[:5]
>     return render_to_response('employees/employees_index.html',
> {'object_list': object_list})
> ----
> 
> How would you process the Salary field of the Data model such that it
> returns the value so that it's processed and is comma separated.  So
> '80000' for Salary would become '80,000'?

Since this is a presentation issue, rather than a data collection issue,
it is something you would probably do directly in the template.

There are a set of filters you can use in your template to do things
like this. They are in the "humanize" template tag package:
http://www.djangoproject.com/documentation/add_ons/#humanize

In you case, the intcomma filter does what you want, so
{{ object.Salary|intcomma }} or something similar.

Regards,
Malcolm



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

Reply via email to