Add view name to template for nicer styling
This commit is contained in:
parent
f3ab567e47
commit
27298cd707
4 changed files with 12 additions and 2 deletions
|
@ -14,7 +14,7 @@
|
|||
<link rel="stylesheet" href="{% static 'css/font-awesome.min.css' %}" />
|
||||
<link rel="stylesheet" href="{% static 'css/index.css' %}" />
|
||||
</head>
|
||||
<body>
|
||||
<body class="{{ view_name }}">
|
||||
|
||||
<header id="top">
|
||||
<nav>
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
from django.conf import settings
|
||||
from django.utils.text import slugify
|
||||
|
||||
|
||||
def settings_injector(request=None):
|
||||
def settings_injector(request):
|
||||
return {"settings": settings}
|
||||
|
||||
|
||||
def view_name(request):
|
||||
return {"view_name": slugify(request.resolver_match.func.__name__)}
|
||||
|
|
|
@ -10,3 +10,7 @@ class HomepageViewTestCase(BaseTestCase):
|
|||
def test_accessible(self):
|
||||
response = self.client.get(reverse("homepage"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_contains_view_name(self):
|
||||
response = self.client.get(reverse("homepage"))
|
||||
self.assertContains(response, '<body class="homepageview">')
|
||||
|
|
|
@ -62,6 +62,7 @@ TEMPLATES = [
|
|||
"django.template.context_processors.debug",
|
||||
"django.template.context_processors.request",
|
||||
"website.common.context_processors.settings_injector",
|
||||
"website.common.context_processors.view_name",
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
Reference in a new issue