From fa014aa11d10ea1b5c84f7a06742cd0aeb22865e Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 23 Feb 2023 10:00:23 +0100 Subject: [PATCH] first commit --- .DS_Store | Bin 0 -> 6148 bytes manage.py | 22 ++++ padel/__init__.py | 0 padel/asgi.py | 16 +++ padel/settings.py | 124 ++++++++++++++++++ padel/urls.py | 22 ++++ padel/wsgi.py | 16 +++ scores/.DS_Store | Bin 0 -> 6148 bytes scores/__init__.py | 0 scores/admin.py | 8 ++ scores/apps.py | 6 + scores/migrations/0001_initial.py | 44 +++++++ .../0002_match_team2scorecolumn5.py | 19 +++ ..._alter_match_team1scorecolumn1_and_more.py | 88 +++++++++++++ scores/migrations/0004_match_court.py | 18 +++ scores/migrations/__init__.py | 0 scores/models.py | 35 +++++ scores/static/.DS_Store | Bin 0 -> 6148 bytes scores/static/scores/style.css | 41 ++++++ scores/templates/.DS_Store | Bin 0 -> 6148 bytes scores/templates/scores/index.html | 80 +++++++++++ scores/tests.py | 3 + scores/urls.py | 23 ++++ scores/views.py | 12 ++ 24 files changed, 577 insertions(+) create mode 100644 .DS_Store create mode 100755 manage.py create mode 100644 padel/__init__.py create mode 100644 padel/asgi.py create mode 100644 padel/settings.py create mode 100644 padel/urls.py create mode 100644 padel/wsgi.py create mode 100644 scores/.DS_Store create mode 100644 scores/__init__.py create mode 100644 scores/admin.py create mode 100644 scores/apps.py create mode 100644 scores/migrations/0001_initial.py create mode 100644 scores/migrations/0002_match_team2scorecolumn5.py create mode 100644 scores/migrations/0003_alter_match_team1_alter_match_team1scorecolumn1_and_more.py create mode 100644 scores/migrations/0004_match_court.py create mode 100644 scores/migrations/__init__.py create mode 100644 scores/models.py create mode 100644 scores/static/.DS_Store create mode 100644 scores/static/scores/style.css create mode 100644 scores/templates/.DS_Store create mode 100644 scores/templates/scores/index.html create mode 100644 scores/tests.py create mode 100644 scores/urls.py create mode 100644 scores/views.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..bf31fb13c9fc0775842f91f5eb00c8806a65c69f GIT binary patch literal 6148 zcmeHK%}T>S5T5OSC_)bkdJA|JOe_?{OQ`h)jOan7CQZ>`%$6p#hf>I0U&t5nd7RnZ z3bA?B0-_Fj=hW&Qg%>aPt&mtF~0{|^l!it5>H$r~WHK~}98lq5hBvCd>LMan8 zS^fh9w0CuwKmZYpp|pPu$Y2B#rs&ARc{T|X8DjWbI7#9xcbs=osn+U^X47i6o45Xh zocno@&$50ny(a4d4??)=2jOKro)0_Qr!vihI2}(_LL7}TuUrk0aEX)8izzl2%1LkULwKrrvybNZ58TdU0=zg$K2|a^_Ms;;y zqe=io`i)eAeX1oW$2RC0EHt7AMd(ySohnR;A#^&9+a}I4SZLJgAWZQg%$J3!P=xwA z&Tp%55S~VEnE_^?%s^F}9eV%Iey;z^No+9#%)mx5AZi1D(8nd2w{>lC^w!#_cc>&3 oS7`i9!H#;0F_xa-KKL7v# literal 0 HcmV?d00001 diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..3f39c46 --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'padel.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/padel/__init__.py b/padel/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/padel/asgi.py b/padel/asgi.py new file mode 100644 index 0000000..f8e2f14 --- /dev/null +++ b/padel/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for padel project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'padel.settings') + +application = get_asgi_application() diff --git a/padel/settings.py b/padel/settings.py new file mode 100644 index 0000000..fdddac8 --- /dev/null +++ b/padel/settings.py @@ -0,0 +1,124 @@ +""" +Django settings for padel project. + +Generated by 'django-admin startproject' using Django 4.1.1. + +For more information on this file, see +https://docs.djangoproject.com/en/4.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.1/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-y6eq)a5r)((id1vtb_be!nco92vla2$#iwm^^opa7@x4(%o5mh' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'scores' +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'padel.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'padel.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/4.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.1/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/padel/urls.py b/padel/urls.py new file mode 100644 index 0000000..6d79dd2 --- /dev/null +++ b/padel/urls.py @@ -0,0 +1,22 @@ +"""padel URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import include, path + +urlpatterns = [ + path('', include('scores.urls')), + path('admin/', admin.site.urls), +] diff --git a/padel/wsgi.py b/padel/wsgi.py new file mode 100644 index 0000000..90b2d24 --- /dev/null +++ b/padel/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for padel project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'padel.settings') + +application = get_wsgi_application() diff --git a/scores/.DS_Store b/scores/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..6ab22768f849d08ec30c28583e40291fcf9774ff GIT binary patch literal 6148 zcmeHK&5qMB5FYQAZL%w*9zcSdC9ai7%kCn?CEG18KoA@Nm86Nf5osJHDLqt`a) zapw(?coQU!%-B=WZp)82074$g{v6MYf4-6J3;>A1Ebakx0KmaQ*gC{&hmfAimh5rQ z5u(szgiu2Y3Ua8ntZj#7z%uZ!F+gYc5T*D;GV_>v!ep$?NKUKpav*COx zKVP1G{BX8y6aUnvxcKorZ-O$mxFQ-?!6}9??$|Hc&Sz{48g~$!d^Q#E<{*57wzdpd z1~wVkH=iAP{~vun|KD`7UzP#Oz<(=Jzt(90_VId*A#-Mh=il1ZM gpr`m27A>fg)IjtZ8-v(`Vt)iQ4Yslj{80wJ0%;4twg3PC literal 0 HcmV?d00001 diff --git a/scores/__init__.py b/scores/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scores/admin.py b/scores/admin.py new file mode 100644 index 0000000..db3ab4e --- /dev/null +++ b/scores/admin.py @@ -0,0 +1,8 @@ +from django.contrib import admin + +# Register your models here. +from .models import Club +from .models import Match + +admin.site.register(Club) +admin.site.register(Match) diff --git a/scores/apps.py b/scores/apps.py new file mode 100644 index 0000000..14a148d --- /dev/null +++ b/scores/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ScoresConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'scores' diff --git a/scores/migrations/0001_initial.py b/scores/migrations/0001_initial.py new file mode 100644 index 0000000..19014aa --- /dev/null +++ b/scores/migrations/0001_initial.py @@ -0,0 +1,44 @@ +# Generated by Django 4.1.1 on 2023-02-22 16:36 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Club', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=200)), + ], + ), + migrations.CreateModel( + name='Match', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('date', models.DateTimeField(verbose_name='start date')), + ('title', models.CharField(max_length=200)), + ('team1', models.CharField(max_length=200)), + ('team2', models.CharField(max_length=200)), + ('team3', models.CharField(max_length=200)), + ('team4', models.CharField(max_length=200)), + ('team1scorecolumn1', models.CharField(max_length=200)), + ('team1scorecolumn2', models.CharField(max_length=200)), + ('team1scorecolumn3', models.CharField(max_length=200)), + ('team1scorecolumn4', models.CharField(max_length=200)), + ('team2scorecolumn1', models.CharField(max_length=200)), + ('team2scorecolumn2', models.CharField(max_length=200)), + ('team2scorecolumn3', models.CharField(max_length=200)), + ('team2scorecolumn4', models.CharField(max_length=200)), + ('team1scorecolumn5', models.CharField(max_length=200)), + ('club', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='scores.club')), + ], + ), + ] diff --git a/scores/migrations/0002_match_team2scorecolumn5.py b/scores/migrations/0002_match_team2scorecolumn5.py new file mode 100644 index 0000000..d1331d8 --- /dev/null +++ b/scores/migrations/0002_match_team2scorecolumn5.py @@ -0,0 +1,19 @@ +# Generated by Django 4.1.1 on 2023-02-22 16:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('scores', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='match', + name='team2scorecolumn5', + field=models.CharField(default=0, max_length=200), + preserve_default=False, + ), + ] diff --git a/scores/migrations/0003_alter_match_team1_alter_match_team1scorecolumn1_and_more.py b/scores/migrations/0003_alter_match_team1_alter_match_team1scorecolumn1_and_more.py new file mode 100644 index 0000000..0b96695 --- /dev/null +++ b/scores/migrations/0003_alter_match_team1_alter_match_team1scorecolumn1_and_more.py @@ -0,0 +1,88 @@ +# Generated by Django 4.1.1 on 2023-02-22 16:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('scores', '0002_match_team2scorecolumn5'), + ] + + operations = [ + migrations.AlterField( + model_name='match', + name='team1', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='team1scorecolumn1', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='team1scorecolumn2', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='team1scorecolumn3', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='team1scorecolumn4', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='team1scorecolumn5', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='team2', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='team2scorecolumn1', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='team2scorecolumn2', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='team2scorecolumn3', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='team2scorecolumn4', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='team2scorecolumn5', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='team3', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='team4', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AlterField( + model_name='match', + name='title', + field=models.CharField(blank=True, max_length=200), + ), + ] diff --git a/scores/migrations/0004_match_court.py b/scores/migrations/0004_match_court.py new file mode 100644 index 0000000..c3cebd4 --- /dev/null +++ b/scores/migrations/0004_match_court.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.1 on 2023-02-22 16:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('scores', '0003_alter_match_team1_alter_match_team1scorecolumn1_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='match', + name='court', + field=models.IntegerField(default=0), + ), + ] diff --git a/scores/migrations/__init__.py b/scores/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scores/models.py b/scores/models.py new file mode 100644 index 0000000..039a9ca --- /dev/null +++ b/scores/models.py @@ -0,0 +1,35 @@ +from django.db import models +import datetime +from datetime import timedelta + +class Club(models.Model): + name = models.CharField(max_length=200) + + def __str__(self): + return self.name + +class Match(models.Model): + club = models.ForeignKey(Club, on_delete=models.CASCADE) + date = models.DateTimeField('start date') + court = models.IntegerField(default=0) + + title = models.CharField(max_length=200, blank=True) + team1 = models.CharField(max_length=200, blank=True) + team2 = models.CharField(max_length=200, blank=True) + team3 = models.CharField(max_length=200, blank=True) + team4 = models.CharField(max_length=200, blank=True) + + team1scorecolumn1 = models.CharField(max_length=200, blank=True) + team1scorecolumn2 = models.CharField(max_length=200, blank=True) + team1scorecolumn3 = models.CharField(max_length=200, blank=True) + team1scorecolumn4 = models.CharField(max_length=200, blank=True) + team1scorecolumn5 = models.CharField(max_length=200, blank=True) + team2scorecolumn1 = models.CharField(max_length=200, blank=True) + team2scorecolumn2 = models.CharField(max_length=200, blank=True) + team2scorecolumn3 = models.CharField(max_length=200, blank=True) + team2scorecolumn4 = models.CharField(max_length=200, blank=True) + team2scorecolumn5 = models.CharField(max_length=200, blank=True) + + # def duration(self): + # delta = datetime.now().date() - date + # return str(timedelta(delta)) diff --git a/scores/static/.DS_Store b/scores/static/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2e86add08fb6e1ddd112e7241b6b02821052eab4 GIT binary patch literal 6148 zcmeHKO-jWu5T4Pe6x_U}%N)SXyFo4S1n&aUR&>#lhsAv^<0V{s125z^nNeC_!G$0q zGmw0f%ukvRnq-KGo2Pz9v?ZbnO^`)d5t&{!otX0(kV}p`n)<05+LVTsM1OHgzWtmg z>L}48&AuNSS{jD?-M&lXVYZ7!;Fw};ht$GeJ-=MV=I!8dl} z3^)VMfHUw@2IPu^R2PcgI|I&uGw{iPoDTs_ur|z!<>)|HN&w&n(?y_5Eg><%ur|z! zus~Qtff~wIVz7o|KA2x^m=!gg*oqIfl|PCXE~_JdDDK3yqW8{#Gq7afREJx+|8MZi ztQPsp5Fa@M&cHuofH!d;8*Iw%)}!soT^rDD(L}^AivoeZcm!Y|=g4I-sy&DfzuGV> UN*0+f;Xr=~6hgdn27ZBocdGI-*#H0l literal 0 HcmV?d00001 diff --git a/scores/static/scores/style.css b/scores/static/scores/style.css new file mode 100644 index 0000000..f34f9a2 --- /dev/null +++ b/scores/static/scores/style.css @@ -0,0 +1,41 @@ +a { + color: white; +} + +html { + font-size: 30px; /* px signifie 'pixels': la taille de base pour la police est désormais 10 pixels de haut */ + font-family: 'Open Sans', sans-serif; /* cela devrait être le reste du résultat obtenu à partir de Google fonts */ + background-color: #438FFF; + color: white; +} + +table { + font-size: 40px; /* px signifie 'pixels': la taille de base pour la police est désormais 10 pixels de haut */ + font-weight: 600; +} + +table, th, td { + border: 1px solid; + border-color: white; + border-collapse: collapse; +} + +td { + padding: 10px; +} + +.score { + width: 50px; + text-align: center; + vertical-align: middle; +} + +.match { + /* display: inline-block; */ + /* background-color: red; */ +} + +.container { + /* width: 100%; */ + /* margin: 0 auto; */ +} diff --git a/scores/templates/.DS_Store b/scores/templates/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b3d21f9b28c781e34186f2caaeea111064608463 GIT binary patch literal 6148 zcmeHK%}T^D5T4O01uuK_m{(Yzpf2?Z_64M^=%FRc7VkX^zR@1{4SXTL$&Avt1rLIV z%s}!@GCyfPXp$i!-aL0}q7@O9Xo4)tg2?ou>CBujfShtX(AbS_-^AE2B>Ia}^6i&2 zQcIEcH2Z#RC^z(v>uno{-E0?G;1KJ&>0<+Xd3Y^eZr+Z!Uvmtx`_^aobh6HDNmrc# zXTTY72AqMPG9XtRq`Xq}-WhNPoPkdU{u!fAEn56PXlQuN*#a0YS)&ULtw`~MEV z%wmzBhxo`Da0dPv16 Vijqa + + + + Padel kikou + + + + + +
+{% if matches %} +
+ {% for match in matches %} +

Cours #{{ match.court }} - {{ match.title }}

+ +

{{ match.duration }}

+ + + + + {% if match.team1scorecolumn1 %}{% endif %} + {% if match.team1scorecolumn2 %}{% endif %} + {% if match.team1scorecolumn3 %}{% endif %} + {% if match.team1scorecolumn4 %}{% endif %} + {% if match.team1scorecolumn5 %}{% endif %} + + + + {% if match.team2scorecolumn1 %}{% endif %} + {% if match.team2scorecolumn2 %}{% endif %} + {% if match.team2scorecolumn3 %}{% endif %} + {% if match.team2scorecolumn4 %}{% endif %} + {% if match.team2scorecolumn5 %}{% endif %} + +
{{ match.team1 }}{{ match.team1scorecolumn1 }}{{ match.team1scorecolumn2 }}{{ match.team1scorecolumn3 }}{{ match.team1scorecolumn4 }}{{ match.team1scorecolumn5 }}
{{ match.team2 }}{{ match.team2scorecolumn1 }}{{ match.team2scorecolumn2 }}{{ match.team2scorecolumn3 }}{{ match.team2scorecolumn4 }}{{ match.team2scorecolumn5 }}
+ + {% endfor %} +
+ +{% else %} +

No matches at the moment...

+{% endif %} +
+ + + + + diff --git a/scores/tests.py b/scores/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/scores/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/scores/urls.py b/scores/urls.py new file mode 100644 index 0000000..0bc9ea4 --- /dev/null +++ b/scores/urls.py @@ -0,0 +1,23 @@ +"""padel URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.index, name='index'), +] diff --git a/scores/views.py b/scores/views.py new file mode 100644 index 0000000..c8d7389 --- /dev/null +++ b/scores/views.py @@ -0,0 +1,12 @@ +from django.shortcuts import render +from django.http import HttpResponse +from django.template import loader +from .models import Match + +def index(request): + matches = Match.objects.order_by('-court') + template = loader.get_template('scores/index.html') + context = { + 'matches': matches, + } + return HttpResponse(template.render(context, request))