Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 5 Bookmarks problem with <li {% if section == 'dashboard' %} class="selected"> #104

Open
smtoff opened this issue Nov 22, 2021 · 2 comments

Comments

@smtoff
Copy link

smtoff commented Nov 22, 2021

Just going through the book and came across this problem Page 206. Using Pycharm community and Windows 10.
It is saying the template tag {% if section == 'dashboard' %} is not allowed inside the <li> html tag. Tried to find a solution online but not very helpful especially with combination of css, html and django template language.
Have a workaround but it's a bit messy and I am trying to get through the book so wondered if there was a solution.
Have changed each of the following

  <li {% if section == "dashboard" %}class="selected"{% endif %}>
    <a href="{% url "dashboard" %}">My dashboard</a>
  </li>

to

      {% if section == 'dashboard' %}
        <li  class="selected">
        <a href="{% url 'dashboard' %}">My dashboard</a>
        </li>
      {% else %}
        <li>
        <a href="{% url 'dashboard' %}">My dashboard</a>
        </li>
      {% endif %}

As you can see code is now a bit messy any other way this can be done?
Thanks

@smtoff
Copy link
Author

smtoff commented Nov 23, 2021

Thanks but think I changed the double quotes in the original as well and still had problem. Pycharm and django gave definite error messages that stated the {% was not allowed in the html tag type.

@diegobarbo
Copy link

Same issue too.. sadly for I can't find a solution all over the internet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants