Templating

parent 1bf247f6
Pipeline #29078 canceled with stages
<html>
<head>
<title>PyMonitoring</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
</head>
<body>
<div class="page-header">
<h1><a href="/">HOME IS HERE</a></h1>
</div>
<div class="content container">
<div class="row">
<div class="col-md-8">
{% block content %}
{% endblock %}
</div>
</div>
</div>
</body>
</html>
{% extends "base.html" %}
{% block content %}
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
<form method="post" action="{% url 'login' %}">
{% csrf_token %}
<table>
<tr>
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
</tr>
<tr>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</tr>
</table>
<input type="submit" value="login" />
<input type="hidden" name="next" value="{{ next }}" />
</form>
{% endblock %}
from django.urls import path, include
from . import views
from django.conf.urls import url
from django.contrib import admin
urlpatterns = [
path('', views.index, name='index'),
path('api', views.api, name='api'),
url(r'^accounts/login/$', views.login, name='login'),
]
from django.shortcuts import render
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required
# Create your views here.
def index(request):
return render(request, 'base.html')
@login_required
def api(request):
return HttpResponse("API")
def login(request):
return render(request, 'login.html')
No preview for this file type
......@@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dashboard',
]
MIDDLEWARE = [
......
......@@ -15,7 +15,10 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path
from django.conf.urls import include
from django.conf.urls import url
urlpatterns = [
path('admin/', admin.site.urls),
url(r'', include('dashboard.urls')),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment