Creative-Tim
.Links
python --version
. Here is the full list of dependencies and tools required to build the app:Docker
- a popular virtualization softwareπ Step 1 - Download the code from the GH repository (usingGIT
)
π Step 2 - Start the APP inDocker
http://localhost:5085
in your browser. The app should be up & running.Download the code
Unix
, MacOS
Install modules viaVENV
Set Up Database
Start the app
http://127.0.0.1:8000/
.Windows
Install modules viaVENV
(windows)
Set Up Database
Start the app
http://127.0.0.1:8000/
.Users
superusers
) follow up the next sections.Superusers
admin
section, Django requires superuser
privilegies. Let's create a new superuser
and access the admin
section of the project:superuser
is successfully created, we can access the admin
section:http://localhost:8000/admin/
(make sure you have a /
at the end).python manage.py runserver
registration
page and create a new user:http://127.0.0.1:8000/register/
sign in
page and authenticatehttp://127.0.0.1:8000/login/
core.settings.py
file where the project configuration is bundled. The most important files
that make the project functional are listed below:manage.py
(saved in the root of the project) loads core/settings.py
core/settings.py
:.env
file (dynamic configuration)core.urls.py
templates
directoryapps/templates
INSTALLED_APPS
sectionapps.home
- custom app that serve all pagesDB_ENGINE
variable is not present in the environmentSQLite
persistence is usedDB_ENGINE
is presentMySql
or PostgreSQL
.core/urls.py
.home
application being a generic router that serves all pages defined in the templates/home
directory, should be the last rule defined in the urlpatterns
.NOTE: all new apps, should be included aboveapps.home.urls
generic rule.
apps/templates
directory. Here are the standard directories:templates/layouts
: UI masterpagestemplates/includes
: UI components (used across multiple pages)templates/accounts
: login & registration pagetemplates/home
: all other pages served via a generic routing by apps/home
appJS
, CSS
, images
) are saved inside the apps/static/assets
folder. This path can be customized with ease via ASSETS_ROOT
variable saved in the .env
file.How it works
.env
defines the ASSETS_ROOT
variablecore/settings.py
read the value of ASSETS_ROOT
and defaults to /static/assets
if not found:ASSETS_ROOT
variable. Here is a sample extracted from templates/layouts/base.html
:href
property is resolved to /static/assets/css/style.css
based on the value saved in the .env
file:apps/templates/home
directory.apps/authentication
handles the authentication routes login
, register
. The most important files that make the authentication usable, are listed below:forms.py
- defines the Login, Registration formsviews.py
- implements the login, registration flowroutes.py
- map routing rules over the viewsmodels.py
- EMPTY filetemplates/home
directory to authenticated users. In case a page is not found, a generic page is returned using a 404
HTTP error status.Step 1 - Create the MySql Database to be used by the app
Create a new MySql
databaseCreate a new user
and assign full privilegies (read/write)Step 2 - Installmysqlclient
package
Step 3 - Edit the.env
to match your MySql DB credentials. Make sureDB_ENGINE
is set tomysql
.
DB_ENGINE
: mysql
DB_NAME
: default value = appseed_db
DB_HOST
: default value = localhost
DB_PORT
: default value = 3306
DB_USERNAME
: default value = appseed_db_usr
DB_PASS
: default value = pass
MySql
for the persistence layer.polls
.Create a new app usingstartapp
command (make sure you are in the root of the project)
Write a simple view for the new app - Editpolls/views.py
Create urls.py inside thepolls
directory
Update project routing -core/urls.py
file:
Enable the new app - Updatecore/settings.py
file:
Start the project and access the project in the browser:
http://localhost:8000/polls/
production
apps/static/assets
- the folder where JS
, CSS
, and images
files are savedASSETS_ROOT
- environment variable, that defaults to /static/assets
if not definedapps/static/assets
files should be copied to an external (public) directory and the ASSETS_ROOT
environment variable updated accordingly.static
files are copied to https://cdn.your-server.com/datta-able-assets
, the .env
file should be updated as below:live demo
) for more features and improved UIBootstrap 5
version