· 7 years ago · Nov 12, 2018, 08:54 AM
1"""
2Django settings for courses_django project.
3
4Generated by 'django-admin startproject' using Django 2.1.3.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/2.1/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/2.1/ref/settings/
11"""
12
13import os
14
15# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17
18# Quick-start development settings - unsuitable for production
19# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
20
21# SECURITY WARNING: keep the secret key used in production secret!
22SECRET_KEY = 'p@8k2c(&6&2q-*ak+b6blic@$%%^%@-cckn^+(vp(sy9m60t@%'
23
24# SECURITY WARNING: don't run with debug turned on in production!
25DEBUG = True
26
27ALLOWED_HOSTS = []
28
29# Application definition
30
31INSTALLED_APPS = [
32 'django.contrib.admin',
33 'django.contrib.auth',
34 'django.contrib.contenttypes',
35 'django.contrib.sessions',
36 'django.contrib.messages',
37 'django.contrib.staticfiles',
38 'lesson_one',
39 'lesson_two',
40 'lesson_two_part2',
41 'lesson_two_response',
42 'lesson_third',
43]
44
45MIDDLEWARE = [
46 'django.middleware.security.SecurityMiddleware',
47 'django.contrib.sessions.middleware.SessionMiddleware',
48 'django.middleware.common.CommonMiddleware',
49 'django.middleware.csrf.CsrfViewMiddleware',
50 'django.contrib.auth.middleware.AuthenticationMiddleware',
51 'django.contrib.messages.middleware.MessageMiddleware',
52 'django.middleware.clickjacking.XFrameOptionsMiddleware',
53]
54
55ROOT_URLCONF = 'courses_django.urls'
56
57TEMPLATES = [
58 {
59 'BACKEND': 'django.template.backends.django.DjangoTemplates',
60 'DIRS': [os.path.join(BASE_DIR, 'templates')],
61 'APP_DIRS': True,
62 'OPTIONS': {
63 'context_processors': [
64 'django.template.context_processors.debug',
65 'django.template.context_processors.request',
66 'django.contrib.auth.context_processors.auth',
67 'django.contrib.messages.context_processors.messages',
68 ],
69 },
70 },
71]
72
73WSGI_APPLICATION = 'courses_django.wsgi.application'
74
75# Database
76# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
77
78DATABASES = {
79 'default': {
80 'ENGINE': 'django.db.backends.sqlite3',
81 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
82 }
83}
84
85# Password validation
86# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
87
88AUTH_PASSWORD_VALIDATORS = [
89 {
90 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
91 },
92 {
93 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
94 },
95 {
96 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
97 },
98 {
99 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
100 },
101]
102
103# Internationalization
104# https://docs.djangoproject.com/en/2.1/topics/i18n/
105
106LANGUAGE_CODE = 'en-us'
107
108TIME_ZONE = 'UTC'
109
110USE_I18N = True
111
112USE_L10N = True
113
114USE_TZ = True
115
116# Static files (CSS, JavaScript, Images)
117# https://docs.djangoproject.com/en/2.1/howto/static-files/
118
119STATIC_URL = '/static/'
120'
121
122from django.conf.urls import url, include
123
124from django.contrib import admin
125# from lesson_two import views
126
127urlpatterns = [
128 # url(r'', include('lesson_one.urls')),
129 # path(r'^ admin/', admin.site.urls),
130 # url(r'^', views.home),
131 # url(r'^', include('lesson_two.urls')),
132 # url(r'^', include('lesson_two_part2.urls')),
133 # url(r'^lesson-two-response/', include('lesson_two_response.urls')),
134 url(r'^lesson-third/', include('lesson_third.urls')),
135]
136
137from django.shortcuts import render
138import datetime, math
139from django.http import HttpResponse
140from django.template import loader
141
142
143# Create your views here.
144
145def view(request):
146 list = [0, 232, 4, 555, 654, 54, 12]
147 template = loader.get_template('index.html')
148 context = {
149 "test": "TEXT",
150 "list": list,
151 "name": "ALEX",
152 "surname": "Ivanov",
153 "coords": {
154 "x": "x coords",
155 "y": "y coords",
156 },
157 'list': [1, 2, 3, 4]
158 }
159
160from django.conf.urls import url, include
161from . import views
162
163urlpatterns = [
164 url(r'^view$', views.view)
165]
166
167{% load poll_extras %}
168
169<!DOCTYPE html>
170<html lang="en">
171<head>
172 <meta charset="UTF-8">
173 <title>Title</title>
174 <style>
175 ol.variables li, ol.filters li span {
176 font-size: 32px;
177 color: red;
178 }
179 </style>
180</head>
181<body>
182<h1>Hello 3 lesson</h1>
183<h2>{{test}}</h2>
184<h2>Variables:</h2>
185
186 <ol clas="variables">
187 <li>Name: {{name}}</li>
188 <li>Surname: {{surname}}</li>
189 <li>Coords.x: {{coords.x}}</li>
190 <li>Coords.y: {{coords.y}}</li>
191 <li>list[0]: {{qwerty}}</li>
192 <li></li>
193</ol>
194</body>
195</html>
196
197System check identified no issues (0 silenced).
198November 12, 2018 - 13:33:13
199Django version 2.1.3, using settings 'courses_django.settings'
200Starting development server at http://127.0.0.1:8000/
201Quit the server with CTRL-BREAK.
202Not Found: /
203[12/Nov/2018 13:36:42] "GET / HTTP/1.1" 404 1937
204Not Found: /lesson-two-response/render-template/
205[12/Nov/2018 13:36:48] "GET /lesson-two-response/render-template/ HTTP/1.1" 404 2063
206Not Found: /favicon.ico
207[12/Nov/2018 13:36:49] "GET /favicon.ico HTTP/1.1" 404 1988
208Not Found: /lesson-third/view/
209[12/Nov/2018 13:36:57] "GET /lesson-third/view/ HTTP/1.1" 404 2062