Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJay See
6,880 PointsIs there are way to apply |pluralize to are/is in django similar to using |pluralize?
At the moment when there is one item the line reads: "These are 1 step "
2 Answers
Katie Wood
19,141 PointsSo now that I'm reading your question correctly, it seems that what you actually want to know is if you can have a string response using functionality like |pluralize also update the is/are to form a correct sentence.
I'm not a Django expert, so anyone who knows more than I do should feel free to contribute here as well, but blocktrans has one of the best examples I personally know of for doing something like what you're asking in a Django context. It has some aspects of a conditional, but is fairly concise:
{% blocktrans count counter=list|length %}
There is only one {{ name }} object.
{% plural %}
There are {{ counter }} {{ name }} objects.
{% endblocktrans %}
I hope this is helpful! Certainly more helpful than my misreading the question, I'm sure :)
Jay See
6,880 PointsNo not at all! Great answer anyway - I appreciate the help!
Katie Wood
19,141 PointsNo worries - I updated my answer to specifically address Django template tags. It's entirely possible that there's a better way I don't know about though, so I'm interested to see if any other answers pop up. :)
Jay See
6,880 PointsJay See
6,880 PointsThanks Katie!
That works a treat. Apologies, my question was worded poorly :)
I was wondering on context to django template tags.
Katie Wood
19,141 PointsKatie Wood
19,141 PointsI noticed that right before seeing your response - that's not your fault at all. I paid too much attention to "Python" and the question text and not enough to the actual title, which was a silly mistake. I'm updating the answer in a Django context - sorry about that!