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 :: transpose([[1],[2],[3]]) 
Python :: print(s[::-1]) 
Python :: exception: python in worker has different version 3.7 than that in driver 3.8, pyspark cannot run with different minor versions. please check environment variables pyspark_python and pyspark_driver_python are correctly set. 
Python :: function palindrome python 
Python :: pubmed database python 
Python :: python you bad 
Python :: how to get source code of website in python 
Python :: convolutional layer of model architecture pass input_shape 
Python :: swap two elements in list python 
Python :: # str and int mixup in python: 
Python :: dadfa 
Python :: labelling row in python 
Python :: &eacute;liminer le background image python 
Python :: video in python without cv2 
Python :: python function changing arguments 
Python :: django admin link column display links 
Python :: image processing for GC 
Python :: add label on choropleth map python 
Python :: telecharger pade python 
Python :: flask get summernote text 
Python :: turn off slip in frozen lake openai gym 
Python :: pylint no name in module opencv 
Python :: code runner runs python 2 
Python :: train chatterbot using yml 
Python :: creating a frequency table | generating a frequency table 
Python :: example of a bad code 
Python :: repeats in python 
Python :: matplotlib FiveThirtyEight horizontal graph 
Python :: test if instance in queryset django 
Python :: pandas corr get couple value 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =