0

I have multiple online forms that I'm working on and there will be several pull down menus with different numeric ranges.

For example I need a simple template loop from 0 to 100 that will be used in an online form.

Is there something that does not require some custom views or such?

Was thinking something like this:

{% for i in x |range[0, 100] %}
  <option value="{{ i }}">{{ i }}</option>
{% endfor %}
WayBehind
  • 1,607
  • 3
  • 39
  • 58
  • Could you be clarify your question? – felipsmartins Jun 04 '14 at 17:32
  • I have multiple online forms that I'm working on and there will be several pull down menus with different numeric ranges. – WayBehind Jun 04 '14 at 17:39
  • possible duplicate of [Numeric for loop in Django templates](http://stackoverflow.com/questions/1107737/numeric-for-loop-in-django-templates) – Maxime Lorant Jun 04 '14 at 17:41
  • 1
    Maxime, I saw that thread. It is from 2009 and I'm hoping that Django evolved since then and that there are some better solutions than some custom snippets for something so simple. – WayBehind Jun 04 '14 at 17:47
  • @WayBehind, if this thing does not exist (and it actually still doesn't), it's not because Django is bad, it's because it's not the template role to do such a thing. Watch the xjtian answer. – David Dahan Jun 04 '14 at 22:12

1 Answers1

1

The best and easiest approach would be to pass in a range(0, 100) in the response context through your view. You could also write your own range template filter, or search for an existing one on the web - I'm sure there are existing implementations out there.

xjtian
  • 966
  • 1
  • 7
  • 15