1
Fork 0

Add actual pages to navbar

This commit is contained in:
Jake Howard 2018-07-26 09:22:19 +01:00
parent 739c870a69
commit 842ccae297
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 15 additions and 7 deletions

View file

@ -1,5 +1,5 @@
from django.conf import settings from django.conf import settings
from project.home.models import HomePage
SETTINGS_KEYS = [ SETTINGS_KEYS = [
'BASE_URL', 'BASE_URL',
@ -16,3 +16,8 @@ def settings_injector(request):
return {'settings': { return {'settings': {
setting: getattr(settings, setting) for setting in SETTINGS_KEYS setting: getattr(settings, setting) for setting in SETTINGS_KEYS
}} }}
def get_home_page(request):
return {
'homepage': HomePage.objects.live().first()
}

View file

@ -102,7 +102,8 @@ TEMPLATES = [
'django.template.context_processors.request', 'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
'project.common.context.settings_injector' 'project.common.context.settings_injector',
'project.common.context.get_home_page'
], ],
}, },
}, },

View file

@ -5,11 +5,13 @@
</button> </button>
<div class="collapse navbar-collapse" id="navbarNav"> <div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav mr-auto"> <ul class="navbar-nav mr-auto">
{% for child in homepage.get_children.specific %}
<li class="nav-item"> <li class="nav-item">
<a href="/" class="nav-link"> <a href="{{ child.url }}" class="nav-link">
<code>~/something</code> <code>~/{{ child.slug }}</code>
</a> </a>
</li> </li>
{% endfor %}
</ul> </ul>
<div class="d-none d-lg-block"> <div class="d-none d-lg-block">