Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

install virtual environments_brew

# install virtual environments brew
mkdir django_website
cd django_website
django_website brew update
django_website brew install pyenv-virtualenv  	# install virtual evnironment which 
django_website pyenv virtualenv 3.8.10 		# help install depandancies for python
							# not conflicted with other 									# depandancies in other project

django_website pyenv virtualenv 3.8.10  djangowebsite@3.8.10	# name virtual 											# environment	
# install vim if you didn't already
django_websitevim .python-version			# create python version file
# in python version file put name djangowebsite@3.8.10
# python-version file automatically activates your virtual environment
# when you " cd " into project directory
# you can also activate it manually by running "pyenv activate djangowebsite@3.8.10" in 
# terminal

django_websitepyenv virtualenvs			# show installed virtual environments	
# in your project folder in vs_code make folder " requirements ".
# in requirements folder make dev.txt and prod.txt
# in dev.txt write
# everything the developer needs in addition to the production requirements
-r prod.txt
#go back to terminal
djangowebsitepip install -r requirements/dev.txt
djangowebsitepip install django
# when install Django it will show in terminal version of Django(Django-3.0.7)
# take that version and put it in " prod.txt " file
# if I want to pin that version I will change Django-3.0.7 to Django==3.0.7
# to check if Django is installed we can run on terminal
djangowebsitepython
djangowebsiteimport django
djangowebsiteprint[django.get_version()]
# press CTRL + D to exit that shell
# django has django-admin with tools for creating project
djangowebsitedjango-admin startproject hackershack	# hackershack is name of proj.
# it will create our boilerplate for our project
# python-boilerplate puts all source code for your project under the src/<package> folder. #This contrasts with the other typical approach of leaving the python packages directly in the #root of the the source tree.
djangowebsitels				# list hackershack website
# if I go to my vs_code project I can see " manage.py " file
# also, have folder " hackershack " with __init__.py, asgi.py, settings.py,urls.py and wsgi.py 
# you can removing nasted folder hackershack by moving all files to parent folder
# you can move manage.py to root
# manage.py is our start point where we type commands to running our server
djangowebsitepython manage.py runserver		# this will start our server for us
							# it start our server at port:8000
# if I open my Chrome and type localhost:8000 you can see my Django site is up and running
					
Comment

PREVIOUS NEXT
Code Example
Python :: python generate pdf from template 
Python :: how can i remove random symbols in a dataframe in Pandas 
Python :: python possible combinations 
Python :: logging 
Python :: python list .remove 
Python :: create the dataframe column based on condition 
Python :: python count how many times a character appears in a string 
Python :: python calculator file size to megabytes 
Python :: what is a print statement 
Python :: pytohn reset all dictionary values to 0 
Python :: numpy array from list 
Python :: python dict remove duplicates where items are not the same 
Python :: django example 
Python :: pandas dataframe get first n rows 
Python :: python cut string to length 
Python :: os chdir python 
Python :: training linear model sklearn 
Python :: django templates 
Python :: arg parse array argument 
Python :: python euclidean distance 
Python :: queryset to list python 
Python :: python lists tuples sets dictionaries 
Python :: cv2 imwrite 
Python :: multiline comment in python 
Python :: tkinter treeview 
Python :: how to replace an element of a list using list comprehension 
Python :: python square number 
Python :: random.choices in python 
Python :: get median using python 
Python :: sequenza di fibonacci python 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =