0

I have a filter that returns a python list ['tlc', 'lbh', ...]

I want to iterate over the results in a template such as

{% for dc in settings_value "MULTIPLE_DATACENTERS_TEST_LIST"  %}
                    <option value="{{dc}}">{{dc}}</option>
                {% endfor %}

but I get an error how can i get this to work, thanks?

  • Refer this https://docs.djangoproject.com/en/2.1/ref/templates/builtins/#cycle – Sakthi Panneerselvam Jan 29 '19 at 13:26
  • you need to use `{% for dc in settings_value "MULTIPLE_DATACENTERS_TEST_LIST".items%}` or `{% for dc in settings_value "MULTIPLE_DATACENTERS_TEST_LIST".values%}` for just values – Ahtisham Jan 29 '19 at 13:28
  • What is `settings_value`? – Daniel Roseman Jan 29 '19 at 13:46
  • 1
    @Ahtisham That answer contains invalid Django syntax. Please avoid answering in comments in any case. – Daniel Roseman Jan 29 '19 at 13:47
  • If you want to access a settings variable, look here: https://stackoverflow.com/questions/433162/can-i-access-constants-in-settings-py-from-templates-in-django – otherwise you'll need to explain what `settings_value` and `MULTIPLE_DATACENTERS_TEST_LIST` are supposed to be, and which one of them you want to iterate over. – Endre Both Jan 29 '19 at 19:16

0 Answers0