Make first view with template work

This commit is contained in:
Jan Philipp Timme 2020-11-01 14:17:05 +01:00
parent 7415ec4bbf
commit fa2443d11d
Signed by: JPT
GPG Key ID: 5F2C85EC6F3754B7
6 changed files with 18 additions and 4 deletions

3
.gitignore vendored
View File

@ -4,3 +4,6 @@ __pycache__
# Ignore sqlite db
*.sqlite3
# Ignore private.py since it contains secrets
shorturl/shorturl/private.py

View File

@ -0,0 +1,2 @@
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'REPLACE THIS VALUE BEFORE USING IT IN PRODUCTION'

View File

@ -9,6 +9,8 @@ https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
# Import private settings from private.py
from .private import *
from pathlib import Path
@ -19,9 +21,6 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'dg0e#z95djls+s_b7o(x8$zc*3%vnr0gy4!8vx#&(9lbw%dwu-'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
@ -54,7 +53,7 @@ ROOT_URLCONF = 'shorturl.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': ['shorturl/templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [

View File

@ -0,0 +1 @@
Foo! Bar!

View File

@ -15,7 +15,9 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.index, name='index'),
]

View File

@ -0,0 +1,7 @@
from django.http import HttpResponse
from django.template import loader
def index(request):
template = loader.get_template('index.html')
context = {}
return HttpResponse(template.render(context, request))