3

Below is the code. how to write nested if else statement on django template?

{%ifequal ser_id  3%}
     <label for="inputMobile" id="field-label" class="col-lg-3 col-md-3  col-sm-3 col-xs-3 control-label">Subscriber Id:</label>
     {%else ifequal ser_id 5%}
              <label for="inputMobile" id="field-label" class="col-lg-3 col-md-3  col-sm-3 col-xs-3 control-label">Phone No:</label>
               {%else%}
               <label for="inputMobile" id="field-label" class="col-lg-3 col-md-3  col-sm-3 col-xs-3 control-label">Mobile No:</label>
    {%endif%}
     {%endifequal%}
1
  • if any one knows corrections please tell me..i am getting error:Invalid block tag on line 28: 'else', expected 'endblock'. Did you forget to register or load this tag? Commented Feb 9, 2017 at 11:48

1 Answer 1

1

I think, you can't mix {% ifequal %} and with {% else %} But ou can do this :

{% if ser_id == 3 %}
  <label for="inputMobile" id="field-label" class="col-lg-3 col-md-3  col-sm-3 col-xs-3 control-label">Subscriber Id:</label>
{% elif ser_id == 5 %}
  <label for="inputMobile" id="field-label" class="col-lg-3 col-md-3  col-sm-3 col-xs-3 control-label">Phone No:</label>
{% else %}
  <label for="inputMobile" id="field-label" class="col-lg-3 col-md-3  col-sm-3 col-xs-3 control-label">Mobile No:</label>
{% endif %} 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.