Django CoreUI
Open-source Django Starter coded on top CoreUI design.
Django Admin Dashboard generated by the AppSeed platform on top of CoreUI design, an iconic free dahsboard template.
Version: v1.0.5 - release date
2022-06-01
Built with CoreUI Generator
UI Kit:
CoreUI
SQLite Database, Django Native ORM
Session-Based Authentication, Forms validation
Deployment scripts: Docker, Gunicorn/Nginx
✨ Environment
To use the starter, Python3 should be installed properly in the workstation. If you are not sure if Python is installed, please open a terminal and type python --version
. Here is the full list with dependencies and tools required to build the app:
Python3 - the programming language used to code the app
GIT - used to clone the source code from the Github repository
Basic development tools (g++ compiler, python development libraries ..etc) used by Python to compile the app dependencies in your environment.
(Optional)
Docker
- a popular virtualization software
✨ Start the app in Docker
👉 Step 1 - Download the code from the GH repository (using
GIT
)
👉 Step 2 - Start the APP in
Docker
Visit http://localhost:5085
in your browser. The app should be up & running.
\
✨ Manual Build
Download the code
\
👉 Set Up for Unix
, MacOS
Unix
, MacOS
Install modules via
VENV
Set Up Database
Start the app
At this point, the app runs at http://127.0.0.1:8000/
.
\
👉 Set Up for Windows
Windows
Install modules via
VENV
(windows)
Set Up Database
Start the app
At this point, the app runs at http://127.0.0.1:8000/
.
\
✨ Manage App Users
Users
By default, the starter is not provided with users. To access the private pages and the admin section (reserved for superusers
) follow up the next sections.
👉 Create Superusers
Superusers
To access the admin
section, Django requires superuser
privilegies. Let's create a new superuser
and access the admin
section of the project:
Once the superuser
is successfully created, we can access the admin
section:
http://localhost:8000/admin/
(make sure you have a /
at the end).
\
👉 Create (Ordinary) Users
By default, the app redirects guest users to authenticate. In order to access the private pages, follow this set up:
Start the app via
python manage.py runserver
Access the
registration
page and create a new user:http://127.0.0.1:8000/register/
Access the
sign in
page and authenticatehttp://127.0.0.1:8000/login/
\
✨ Codebase structure
The project is coded using a simple and intuitive structure presented below:
\
✨ Application Bootstrap Flow
The entry point of the project is the 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) loadscore/settings.py
core/settings.py
:Loads the
.env
file (dynamic configuration)Loads the project routing:
core.urls.py
Defines the
templates
directoryapps/templates
Defines the
INSTALLED_APPS
sectionapps.home
- custom app that serve all pages
If the
DB_ENGINE
variable is not present in the environmentSQLite
persistence is used
If the
DB_ENGINE
is presentThe DB URI is built dynamically for
MySql
orPostgreSQL
.
\
✨ Project Routing
The core file that bundles together all routing rules is core/urls.py
.
The 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 above
apps.home.urls
generic rule.
\
✨ UI Assets and Templates
The project comes with a modern UI fully migrated and usable with Django Template Engine.
👉 Page Templates
All pages and components are saved inside the 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 byapps/home
app
\
👉 Static Assets
The static assets used by the project (JS
, 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 theASSETS_ROOT
variablecore/settings.py
read the value ofASSETS_ROOT
and defaults to/static/assets
if not found:
All pages and components use the
ASSETS_ROOT
variable. Here is a sample extracted fromtemplates/layouts/base.html
:
At runtime, the href
property is resolved to /static/assets/css/style.css
based on the value saved in the .env
file:
\
✨ Default Apps
The codebase comes with two simple apps that handle the authentication and serve all pages saved in the apps/templates/home
directory.
👉 Authentication App
This default app defined in 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 fileThe extended user model is NOT provided
👉 Home App
This app returns all pages saved in the templates/home
directory to authenticated users. In case a page is not found, a generic page is returned using a 404
HTTP error status.
\
✨ Customisation
👉 Set up the MySql Database
Note: Make sure your Mysql server is properly installed and accessible.
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 - Install
mysqlclient
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
\
Here is a sample:
At this point, the app should use MySql
for the persistence layer.
👉 Adding a new app
The existing codebase can be extended with ease with new apps and features. Here are the steps that create a new application named polls
.
Create a new app using
startapp
command (make sure you are in the root of the project)
Write a simple view for the new app - Edit
polls/views.py
Create urls.py inside the
polls
directory
Update project routing -
core/urls.py
file:
Enable the new app - Update
core/settings.py
file:
Start the project and access the project in the browser:
http://localhost:8000/polls/
\
👉 Static Assets for production
production
As explained in the Static Assets section, the assets are managed via:
apps/static/assets
- the folder whereJS
,CSS
, andimages
files are savedASSETS_ROOT
- environment variable, that defaults to/static/assets
if not defined
In production, the contents of the apps/static/assets
files should be copied to an external (public) directory and the ASSETS_ROOT
environment variable updated accordingly.
For instance, if the static
files are copied to https://cdn.your-server.com/coreui-assets
, the .env
file should be updated as below:
🚀 Where to go from here
👉 Access the support page in case something is missing
👉 Use CoreUI Generator to generate a new project
👉 Check-out the PREMIUM version, Django Datta Able PRO (
live demo
) for more features and improved UI✅
Bootstrap 5
version✅ More pages & components
✅
Dark-Mode
✅
Dynamic API
feature✅ Priority on support
✅ Django Datta Able PRO -
product page
Last updated