Feb-21-2021, 12:57 PM
will be Grateful for any lead to carry on my road into Django.
## Trying to change the stylesheet page according to a variable in the views.
## Only Works for home page, and other pages didnt work.
any clues? Thanks in Advance.
# Head html Page:
## Trying to change the stylesheet page according to a variable in the views.
## Only Works for home page, and other pages didnt work.
any clues? Thanks in Advance.
# Head html Page:
<meta charset="UTF-8" /> {% if page_styl == 'home-page' %} <link rel="stylesheet" href="{% static 'css/layout.css' %}" /> {% else %} <link rel="stylesheet" href="{% static 'css/{{ page_styl }}.css' %}" /> {% endif %} <title>A.M.W Store | {{ page }}</title># Views Example:
from django.shortcuts import render def index(request): context = { 'page': 'Contact Us', 'page_styl': 'contact' } return render(request, 'contact/contact.html', context)