From 8776e6a8afc6251b92b0fc6ae1b30e7016360cdb Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Mon, 21 May 2018 21:03:08 +0200 Subject: [PATCH] Add home page --- manuels/migrations/0001_initial.py | 20 ++++++++++++++++++++ manuels/models.py | 3 ++- manuels/templates/manuels/base.html | 13 +++++++++++++ manuels/templates/manuels/home_page.html | 6 ++++++ manuels/tests.py | 6 +++++- manuels/views.py | 10 ++++++++-- manuels_collection/settings.py | 1 + manuels_collection/urls.py | 3 +++ 8 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 manuels/migrations/0001_initial.py create mode 100644 manuels/templates/manuels/base.html create mode 100644 manuels/templates/manuels/home_page.html diff --git a/manuels/migrations/0001_initial.py b/manuels/migrations/0001_initial.py new file mode 100644 index 0000000..390161b --- /dev/null +++ b/manuels/migrations/0001_initial.py @@ -0,0 +1,20 @@ +# Generated by Django 2.0.5 on 2018-05-21 18:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Teacher', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ], + ), + ] diff --git a/manuels/models.py b/manuels/models.py index 8387b34..8b6a3c7 100644 --- a/manuels/models.py +++ b/manuels/models.py @@ -2,4 +2,5 @@ from django.db import models class Teacher(models.Model): - first_name = models.CharField() + # first_name = models.CharField() + pass diff --git a/manuels/templates/manuels/base.html b/manuels/templates/manuels/base.html new file mode 100644 index 0000000..a2637c3 --- /dev/null +++ b/manuels/templates/manuels/base.html @@ -0,0 +1,13 @@ + + + + + Manuels - {% block title %}{% endblock %} + + +
+ {% block content %} + {% endblock %} +
+ + \ No newline at end of file diff --git a/manuels/templates/manuels/home_page.html b/manuels/templates/manuels/home_page.html new file mode 100644 index 0000000..9587e5f --- /dev/null +++ b/manuels/templates/manuels/home_page.html @@ -0,0 +1,6 @@ +{% extends 'manuels/base.html' %} +{% block title %}Accueil{% endblock %} + +{% block content %} + +{% endblock %} \ No newline at end of file diff --git a/manuels/tests.py b/manuels/tests.py index 7ce503c..e145d66 100644 --- a/manuels/tests.py +++ b/manuels/tests.py @@ -1,3 +1,7 @@ from django.test import TestCase -# Create your tests here. + +class HomePageTest(TestCase): + def test_home_page_returns_correct_html(self): + response = self.client.get('/') + self.assertTemplateUsed(response, 'manuels/home_page.html') diff --git a/manuels/views.py b/manuels/views.py index 91ea44a..6c320c0 100644 --- a/manuels/views.py +++ b/manuels/views.py @@ -1,3 +1,9 @@ -from django.shortcuts import render +from django.views.generic import CreateView -# Create your views here. +from manuels.models import Teacher + + +class HomePageView(CreateView): + model = Teacher + fields = [] + template_name = 'manuels/home_page.html' diff --git a/manuels_collection/settings.py b/manuels_collection/settings.py index 498c71a..9a3d64b 100644 --- a/manuels_collection/settings.py +++ b/manuels_collection/settings.py @@ -51,6 +51,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'bootstrap4', + 'manuels', ] MIDDLEWARE = [ diff --git a/manuels_collection/urls.py b/manuels_collection/urls.py index fa86544..9d3d849 100644 --- a/manuels_collection/urls.py +++ b/manuels_collection/urls.py @@ -16,6 +16,9 @@ Including another URLconf from django.contrib import admin from django.urls import path +from manuels.views import HomePageView + urlpatterns = [ path('admin/', admin.site.urls), + path('', HomePageView.as_view(), name='home_page'), ]