// Creating URL PATTERN
// go to mainControl - urls.py - look for urlpatterns = []
from . import views
path('', views.home, name='home'),
// Creating home function
// go to mainControl create new file call it views.py
// inside views.py
from django.shortcuts import render
def home(request):
return render(request, 'home.html')
// Creating templates folder from benleolamsbook folder directly
// inside templates folder create new file called: home.html
// go to mainControl - settings.py - look for TEMPLATES = [ ]
// from - 'DIRS': [], to 'DIRS': ['templates'],
// in home.html type:
<h1> Home page </h1>
// go back to http://127.0.0.1:8000/
// see the output ( Home page )
// go to mainControl folder
// create a new folder - static
// inside the STATIC folder paste all the following folders
// assets, css, img, js, vendor, video, master etc.
// go to settings.py - paste the code below
STATIC_URL = 'static/'
// below code should be above is default
STATIC_ROOT = BASE_DIR / 'static'
STATICFILES_DIRS = [
'mainControl/static',
]
// installing COLLECTSTATIC from the TERMNIAL
python manage.py collectstatic
// right after the installation you will see the generated
// folder called "static" direct from your project folder
// enter to install
// to run the static you must have to load like below
{% load static %}
// note if encountered error about static, just load it to the specific folder
// after you need to do the following like:
<link rel="stylesheet"
href="{% static 'vendor/bootstrap/css/bootstrap.min.css'%}">
// and also the following like:
<script src="{% static 'vendor/jquery/jquery.min.js'%}"></script>
// after try to runserver to test if there will no errors
python manage.py runserver
// use to test the program
// --------------------------------------
// to do the shortcup the following below
// drug and drap into your code editor the
// the "Re-Usable folder " rename it into "new project name "
// go to the TERMINAL
cd nameOfProject
// running server to test
python manage.py runserver