Skip to content

Commit b3fc4da

Browse files
Merge pull request #2 from pythonlessons/feature/tutorial_12
Feature/tutorial 12 - user profile
2 parents 61f131c + f52d787 commit b3fc4da

51 files changed

Lines changed: 34649 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

12_Django-user-profile/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
venv
2+
*.pyc
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Django",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${workspaceFolder}/manage.py",
12+
"args": [
13+
"runserver"
14+
],
15+
"django": true
16+
},
17+
]
18+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
python -m venv venv
2+
activate() {
3+
. venv/Sctripts/activate
4+
echo "installing requirements to virtual environment"
5+
pip install -r requirements.txt
6+
}
7+
activate
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
python3 -m venv venv
2+
activate() {
3+
. venv/bin/activate
4+
echo "installing requirements to virtual environment"
5+
pip install -r requirements.txt
6+
}
7+
activate

12_Django-user-profile/db.sqlite3

196 KB
Binary file not shown.

12_Django-user-profile/djang_website/__init__.py

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for djang_website project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djang_website.settings')
15+
16+
application = get_asgi_application()
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
"""
2+
Django settings for djang_website project.
3+
4+
Generated by 'django-admin startproject' using Django 3.1.7.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.1/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/3.1/ref/settings/
11+
"""
12+
13+
from pathlib import Path
14+
15+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16+
BASE_DIR = Path(__file__).resolve().parent.parent
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = '(c@9=wl&3=c#nm@=5#hn$#dpw5zqm0vvmojfcr!d7%&7&ofz2n'
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = []
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
'django.contrib.admin',
35+
'django.contrib.auth',
36+
'django.contrib.contenttypes',
37+
'django.contrib.sessions',
38+
'django.contrib.messages',
39+
'django.contrib.staticfiles',
40+
# Add our new application
41+
'main',
42+
'users',
43+
'tinymce',
44+
'fontawesomefree',
45+
'crispy_forms',
46+
'captcha',
47+
]
48+
49+
AUTH_USER_MODEL = 'users.CustomUser'
50+
51+
MIDDLEWARE = [
52+
'django.middleware.security.SecurityMiddleware',
53+
'django.contrib.sessions.middleware.SessionMiddleware',
54+
'django.middleware.common.CommonMiddleware',
55+
'django.middleware.csrf.CsrfViewMiddleware',
56+
'django.contrib.auth.middleware.AuthenticationMiddleware',
57+
'django.contrib.messages.middleware.MessageMiddleware',
58+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
59+
]
60+
61+
ROOT_URLCONF = 'djang_website.urls'
62+
63+
TEMPLATES = [
64+
{
65+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
66+
'DIRS': [],
67+
'APP_DIRS': True,
68+
'OPTIONS': {
69+
'context_processors': [
70+
'django.template.context_processors.debug',
71+
'django.template.context_processors.request',
72+
'django.contrib.auth.context_processors.auth',
73+
'django.contrib.messages.context_processors.messages',
74+
],
75+
},
76+
},
77+
]
78+
79+
WSGI_APPLICATION = 'djang_website.wsgi.application'
80+
81+
82+
# Database
83+
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
84+
85+
DATABASES = {
86+
'default': {
87+
'ENGINE': 'django.db.backends.sqlite3',
88+
'NAME': BASE_DIR / 'db.sqlite3',
89+
}
90+
}
91+
92+
93+
# Password validation
94+
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
95+
96+
AUTH_PASSWORD_VALIDATORS = [
97+
{
98+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
99+
},
100+
{
101+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
102+
},
103+
{
104+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
105+
},
106+
{
107+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
108+
},
109+
]
110+
111+
112+
# Internationalization
113+
# https://docs.djangoproject.com/en/3.1/topics/i18n/
114+
115+
LANGUAGE_CODE = 'en-us'
116+
117+
TIME_ZONE = 'UTC'
118+
119+
USE_I18N = True
120+
121+
USE_L10N = True
122+
123+
USE_TZ = True
124+
125+
126+
# Static files (CSS, JavaScript, Images)
127+
# https://docs.djangoproject.com/en/3.1/howto/static-files/
128+
129+
STATIC_URL = '/static/'
130+
131+
CRISPY_TEMPLATE_PACK = 'bootstrap4'
132+
133+
LOGIN_REDIRECT_URL = '/'
134+
LOGIN_URL = 'login'
135+
136+
AUTHENTICATION_BACKENDS = ['users.backends.EmailBackend']
137+
138+
RECAPTCHA_PUBLIC_KEY = '6LddA3kgAAAAAPf1mAJmEc7Ku0cssbD5QMha09NT'
139+
RECAPTCHA_PRIVATE_KEY = '6LddA3kgAAAAAJY-2-Q0J3QX83DFJwFR1hXqmN8q'
140+
SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error']
141+
142+
TINYMCE_DEFAULT_CONFIG = {
143+
'custom_undo_redo_levels': 100,
144+
'selector': 'textarea',
145+
"menubar": "file edit view insert format tools table help",
146+
'plugins': 'link image preview codesample contextmenu table code lists fullscreen',
147+
'toolbar1': 'undo redo | backcolor casechange permanentpen formatpainter removeformat formatselect fontselect fontsizeselect',
148+
'toolbar2': 'bold italic underline blockquote | alignleft aligncenter alignright alignjustify '
149+
'| bullist numlist | outdent indent | table | link image | codesample | preview code | tiny_mce_wiris_formulaEditor tiny_mce_wiris_formulaEditorChemistry',
150+
'contextmenu': 'formats | link image',
151+
'block_formats': 'Paragraph=p; Header 1=h1; Header 2=h2',
152+
'fontsize_formats': "8pt 10pt 12pt 14pt 16pt 18pt",
153+
'content_style': "body { font-family: Arial; background: white; color: black; font-size: 12pt}",
154+
'codesample_languages': [
155+
{'text': 'Python', 'value': 'python'}, {'text': 'HTML/XML', 'value': 'markup'},],
156+
'image_class_list': [{'title': 'Fluid', 'value': 'img-fluid', 'style': {} }],
157+
'width': 'auto',
158+
"height": "600px",
159+
'image_caption': True,
160+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""django_website URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/3.1/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.conf import settings
17+
from django.conf.urls.static import static
18+
from django.contrib import admin
19+
from django.urls import path, include
20+
21+
urlpatterns = [
22+
path("", include('users.urls')),
23+
path("", include('main.urls')),
24+
path('admin/', admin.site.urls),
25+
path('tinymce/', include('tinymce.urls')),
26+
]
27+
if settings.DEBUG:
28+
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for djang_website project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djang_website.settings')
15+
16+
application = get_wsgi_application()

0 commit comments

Comments
 (0)