Use this template to speed up your Django development and deliver web-development projects as quickly as possible.
Follow the below steps for local development setup:
Ensure a new repo has been created using this template ('https://github.com/wesordonez/new-web-dev-template')
Create a virtual environment for local development
python3 venv -venv
python3 source bin activate
pip install -r requirements.txt
.env
file inside the project
folder using the included .env.dev
file as a guide.Required env variables are:
NOTE: The secret key is generated using the
get_random_secret_key()
function. Copy this into the.env
file and delete the print statement AFTER the databases and tables have been migrated
Create a new database in postgres (PGAdmin 4) with the name used in the env variabl SQL_NAME
Now in your terminal create database tables using
python manage.py migrate
Your database should be created and ready to use.
IMPORTANT: This step should not be skipped as it may cause problems in the migration history order requiring a restart.
The migrate command should have triggered the get_random_secret_key()
function outputing a secret key. This should be copied into the env
file at this time and the printstatement commented out. A new secret key should be created for the production secret when time for deployment.
Now run the website from the terminal using.
python manage.py runserver
Your website should be available at: http://localhost:8000/
The Django admin page should be available at: http://localhost:8000/admin/
The Wagtail Dashboard page should be available at http://localhost:8000/cms/
Test the website works and the contact form successfully writes data to the created database.
To run Tailwind CSS open a new terminal and run:
cd styling
npm install tailwindcss@latest
npm install cross-env
npm install postcss-simple-vars
Then you should be able to start tailwind which will auto update and watch for changes using this command:
python manage.py tailwind start
Create admin superuser using the following command in terminal:
python manage.py createsuperuser
Follow the prompts and test at: https:localhost:8000/admin/
Note: If you are facing problems starting this program in windows OS, remove logging from project/settings.py
All html, css, js and assets lies inside the templates.
home.html
.base.html
.base.html
to have the same footer and header.To add title to a page use the following tags
{% block title %}lorem impsum {% endblock title %}
{% block description %}lorem impsum{% endblock description %} #meta description
{% block socialTitle %}{{blog.title}} | {% endblock socialTitle %} # open graph title, for socials
{% block socialDescription %}{{blog.meta_description}}{% endblock socialDescription %} # open graph description, for socials
{% block pageType %}article{% endblock pageType %}
{% block pageImage %}{% endblock pageImage %} # social image
To add additional head tags
{% block head_tags %}lorem impsum {% endblock head_tags %}
To add scripts at the end of the elements
{% block scripts %}
<script src="{% static "" %}" />
{% endblock scripts %}
Follow Dunosis documentation to deploy to Digital Ocean App Platform using GitHub Actions.
This template was based heavily on the following template by PaulleDemon
Images are taken from free to use sites such as