Base Project Files
venv Project Virtual Environment
|___ Lib
|___ Scripts
|___ Include
|___ db.sqlite3 DB??
|___ src Project main source folder
|___ db.sqlite3 Automatically-created database
|___ manage.py Server Run
|___ templates HTML templates
| |___ index.htm HTML file(s)
|
|___ project-name Django project
|___ __init__.py Register parent folder as python file
|___ wsgi.py
|___ settings.py
|___ urls.py List of project URLs
|___ views.py Client requests views
|___ home view [code] Home/Root
|___ other views [code] Other pages
[urls.py]:
. Admin URL
http://127.0.0.1:8000/admin/ url(r'^admin/', include(admin.site.urls)),
. Homepage URL
http://127.0.0.1:8000/ url(r'^$', 'djashar1.views.home', name='home'),
[views.py]
1. Create views.py
2. Create function-based view(s) or class-based view(s), such as def home(request)
[settings.py]
Regulate settings such as:
Base directory path, Secret encryption key, Debugging activation, Template debugging activation, Allowed site hosts, Installed apps/tables, Middleware classes (between request and response), Default URLs file, WSGI live application, Databases, Internationizations, Template directories, etc.
Usual settings to regulate:
. SECRET_KEY
. DEBUG
. TEMPLATE_DEBUG
. ALLOWED_HOSTS
. LANGUAGE_CODE
. TEMPLATE_DIRS
[templates]
Folder containing the HTML files, also known as "templates".
1. Create folder on the same level as the project-name folder - not the project base directory.
2. Setup the templates' paths inside the settings.py
3. Create base.html, the base of all other HTML templates, and use {% block content %}
4. Create home.html and inherit its basic structure from base.html, using {% extends "base.html" %}
templates
|___ base.htm
|___ home.htm