pip3 install Django
python -m django --version
django-admin startproject PROJECT_NAMEto create a number of starter files for our project.
cd PROJECT_NAMEto navigate into your new project’s directory.
$ django-admin startproject mysite $ cd mysite
We can view the directory with the
After installing Homebrew, run
brew install tree (Y)
$ sudo apt-get install tree
tree to see the directory:
. ├── manage.py └── mysite ├── __init__.py ├── asgi.py ├── settings.py ├── urls.py └── wsgi.py
manage.pyfile executes commands on our terminal. We won’t have to edit it, but we’ll use it often.
__init.py__is an empty file that tells python that this is a Python package
settings.pyfile contains important configuration settings for our new project.
urls.pycontains directions for where users should be routed after navigating to a certain URL.
wsgi.pyis how Python and webserver communicate
We can open a development server by running
python manage.py runserver.
We’ll see this
Django version 3.0.8, using settings 'mysite.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
127.0.0.1 is localhost. This development server is being run locally on your machine, meaning other people cannot access your website.
This is a running webserver so we have to leave it running while you’re viewing your site in the browser or else you won’t be able to see it.
To view the site, we access
You’ll see a default site that Django has created for us and we’ll modify this.
To stop the server, type ctrl C.
If you have any trouble with the website not reloading for any reason, then stop the server and run the server again.