Use {% url %} instead of hard-coded urls

This commit is contained in:
Adam Goldsmith 2022-01-25 00:03:52 -05:00
parent 29c0afadcc
commit 813e432399
5 changed files with 15 additions and 9 deletions

View File

@ -20,7 +20,7 @@ from django.contrib.auth.views import LoginView, LogoutView
urlpatterns = [
path("", lambda request: redirect("/tasks/")),
path("", lambda request: redirect("/tasks/"), name="root"),
path("tasks/", include("tasks.urls")),
path("rentals/", include("rentals.urls")),
path("admin/", admin.site.urls),

View File

@ -1,7 +1,7 @@
{% extends "base.dj.html" %}
{% block title %}Lockers Index{% endblock %}
{% block admin_link %}/admin/rentals/{% endblock %}
{% block admin_link %}{% url 'admin:app_list' 'rentals' %}{% endblock %}
{% block content %}
<style>
.locker-bank {

View File

@ -43,7 +43,10 @@
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="/">Home</a>
<a href="{% url 'root' %}">Manage</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'tasks:index' %}">Tasks</a>
</li>
<li class="breadcrumb-item">
<a href="{{ tool.get_absolute_url }}">{{ tool.name }}</a>

View File

@ -10,7 +10,10 @@
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="/">Home</a>
<a href="{% url 'root' %}">Manage</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'tasks:index' %}">Tasks</a>
</li>
<li class="breadcrumb-item active" aria-current="page">{{ tool }}</li>
</ol>

View File

@ -10,13 +10,13 @@
integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
crossorigin="anonymous">
<title>
{% block title %}RecMaint{% endblock %}
{% block title %}Claremont MakerSpace{% endblock %}
</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">RecMaint</a>
<a class="navbar-brand" href="{% url 'root' %}">Claremont MakerSpace</a>
<button class="navbar-toggler"
type="button"
data-toggle="collapse"
@ -31,13 +31,13 @@
{% block nav_extra %}{% endblock %}
{% if user.is_staff %}
<a class="nav-item nav-link"
href="{% block admin_link %}/admin{% endblock %}">Admin</a>
href="{% block admin_link %}{% url 'admin:index' %}{% endblock %}">Admin</a>
{% endif %}
{% if user.is_authenticated %}
<a class="nav-item nav-link" href="/auth/logout">Logout: {{ user }}</a>
<a class="nav-item nav-link" href="{% url 'logout' %}">Logout: {{ user }}</a>
{% else %}
<a class="nav-item nav-link"
href="/auth/login?next={{ request.get_full_path }}">Login</a>
href="{% url 'login' %}?next={{ request.get_full_path }}">Login</a>
{% endif %}
</div>
</div>