tags:

views:

41

answers:

1

I have a custom template tag:

def uploads_for_user(user):
    uploads = Uploads.objects.filter(uploaded_by=user, problem_upload=False)
    num_uploads = uploads.count()
    return num_uploads

and I'd like to do something like this, so I can pluralize properly:

{% with uploads_for_user leader as upload_count %}
    {{ upload_count }} upload{{ upload_count|pluralize }}
{% endwith %}

However, uploads_for_user leader doesn't work in this context, because the 'with' tag expects a single value - Django returns:

TemplateSyntaxError at /upload/
u'with' expected format is 'value as name'

Any idea how I can get round this?

+5  A: 

You could turn it into a filter:

{% with user|uploads_for as upload_count %}
Daniel Roseman
Ah - I see. Thank you :)
AP257