· 7 years ago · Nov 11, 2018, 05:04 PM
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
121from django.conf.urls import url, include
122from django.contrib import admin
123# from lesson_two import views
124urlpatterns = [
125 # url(r'', include('lesson_one.urls')),
126 # path(r'^ admin/', admin.site.urls),
127 # url(r'^', views.home),
128 # url(r'^', include('lesson_two.urls')),
129 # url(r'^', include('lesson_two_part2.urls')),
130 url(r'^lesson-two-response/', include('lesson_two_response.urls')),
131 url(r'^lesson-third/', include('lesson_third.urls')),
132]
133
134from django.shortcuts import render
135import datetime, math
136from django.http import HttpResponse
137from django.template import loader
138
139
140# Create your views here.
141
142def view(request):
143 list = [0, 232, 4, 555, 654, 54, 12]
144 template = loader.get_template('index.html')
145 context = {
146 "test": "TEXT",
147 "list": list,
148 "name": "ALEX",
149 "surname": "Ivanov",
150 "coords": {
151 "x": "x coords",
152 "y": "y coords",
153 },
154 'list': [1, 2, 3, 4]
155 }
156 return HttpResponse(template.render(context, request))
157
158from django.conf.urls import url, include
159from . import views
160
161urlpatterns = [
162 url(r'^view$', views.view)
163]
164
165{% load poll_extras %}
166<!DOCTYPE html>
167<html lang="en">
168<head>
169 <meta charset="UTF-8">
170 <title>Title</title>
171 <style>
172 ol.variables li, ol.filters li span {
173 font-size: 32px;
174 color: red;
175 }
176 </style>
177</head>
178<body>
179<h1>Hello 3 lesson</h1>
180<h2>{{test}}</h2>
181<h2>Variables:</h2>
182
183 <ol clas="variables">
184 <li>Name: {{name}}</li>
185 <li>Surname: {{surname}}</li>
186 <li>Coords.x: {{coords.x}}</li>
187 <li>Coords.y: {{coords.y}}</li>
188 <li>list[0]: {{qwerty}}</li>
189 <li></li>
190</ol>
191</body>
192</html>