Python Forum
changing stylesheet according to variable in views
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
changing stylesheet according to variable in views
#1
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:
<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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Django views : positional argument ghoul 0 1,455 Nov-15-2021, 06:02 PM
Last Post: ghoul
  IndentationError: unexpected indent in views.py ift38375 1 2,545 Dec-08-2019, 02:33 PM
Last Post: michael1789
  Posting html values to views/models in Django Malt 1 2,177 Sep-04-2019, 01:44 PM
Last Post: fishhook

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020