Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Second step creating python project

// 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 )      
Comment

Third step creating python project

// 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 
 
Comment

PREVIOUS NEXT
Code Example
Python :: print(s[::-1]) 
Python :: airflow find trigger type 
Python :: python import local file 
Python :: csv utf-8 to iso-8859-1 python 
Python :: receive ouput subprocess call 
Python :: what is the difference between max-width and flex-basis 
Python :: does pygame work on python 3.10.1 
Python :: comment on inclut date et heure en python svp 
Python :: adding if statements and for loop in pyhton with tuple 
Python :: while loop choosing numbers 
Python :: pytorch get intersection between two masks 
Python :: loosen_pickle 
Python :: np array specified lengte same value 
Python :: Iterate through string with index in python using while loop and rang 
Python :: &quot;%(class)s&quot; in django 
Python :: What is shadows built in name? 
Python :: table is not creating in django 
Python :: how to make python faster 
Python :: django get without exception 
Python :: append in dictionary with matrix values 
Python :: add a third dimension matrix dataset python 
Python :: torch.nn.Linear(in_features, out_features, bias=True) discription 
Python :: what should I do when the keras image datagenerato is nit working 
Python :: pyqt create a qmenu on a button click 
Python :: discord.py assign role 
Python :: qq plot using seaborn with regression line 
Python :: auto instagram login 
Python :: set_flip_h( false ) 
Python :: palindrome without using string function in python 
Python :: python last element of list using reverse() function 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =