Apr 22, 2020
DjangoBeginners ยท4 min read
Get started on your own Django web app using this Django quick start installation guide. It only takes a few minutes to get your Django project up and running on your local development server.
Follow the commands below and you'll soon see your Django web application running in your local browser window.
Django Quick Start Steps:
Django Quick Start: Create a virtual environment
macOS Terminal
User-Macbook:~ user$ cd desktop
User-Macbook:desktop user$ python3 -m venv env
User-Macbook:desktop user$ cd env
User-Macbook:env user$ source bin/activate
(env)User-Macbook:env user$
Windows Command Prompt
C:\Users\Owner> cd desktop
C:\Users\Owner\desktop> py -m venv env
C:\Users\Owner\desktop> cd env
C:\Users\Owner\desktop\env> Scripts\activate
(env)C:\Users\Owner\desktop\env>
Open the Windows Command Prompt or Mac Terminal and create a Python virtual environment, then activate it.
Django Quick Start: Django installation command
Install Django macOS Terminal
(env)User-Macbook:env user$ pip install django
Install Django Windows Command Prompt
(env)C:\Users\Owner\desktop\env> pip install django
Install django
in your activated virtual environment.
Django Quick Start: How to make sure Django is installed
Install Django macOS Terminal
(env)User-Macbook:env user$ pip show django
Check Django Install Windows Command Prompt
(env)C:\Users\Owner\desktop\env> pip show django
To check if Django is installed, run the pip show [name of package]
command.
This command displays the name of the package, version number, and other bits of information on the installed package.
Django Quick Start: Create the project using the startproject command
macOS Terminal
(env)User-Macbook:env user$ django-admin startproject mysite
Windows Command Prompt
(env)C:\Users\Owner\desktop\env> django-admin startproject mysite
Run the Django startproject
command to create a Django project named mysite
.
In this case, the full command is django-admin startproject mysite
. If you wish to name your Django project something else, replace mysite
with the name of your choice.
Django Quick Start: If django-admin startproject mysite not working
If the command django-admin startproject mysite
is not working:
Django Quick Start: Create the app using the startapp command
macOS Terminal
(env)User-Macbook:env user$ cd mysite
(env)User-Macbook:mysite user$ python3 manage.py startapp main
Windows Command Prompt
(env)C:\Users\Owner\desktop\env> cd mysite
(env)C:\Users\Owner\desktop\env\mysite> py manage.py startapp main
Next, you need to run the Django startapp
command in the command prompt.
Enter into the mysite folder then create a Django application named main
with the command python3 manage.py startapp main
or py manage.py startapp main
.
Django Quick Start: Run the development server
macOS Terminal
(env)User-Macbook:mysite user$ python3 manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
February 26, 2019 - 09:54:26
Django version 3.0.6, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-C.
Windows Command Prompt
(env) C:\Users\Owner\Desktop\Code\env\mysite>py manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
February 26, 2019 - 09:54:26
Django version 3.0.6, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-C.
Type the command python3 manage.py runsever
for Mac and py manage.py runserver
for Windows.
Django Quick Start: Open the development server address in your browser
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-C.
Look for the address http://127.0.0.1:8000/ above in the CLI then copy and paste this URL in a new browser window. A web page with a rocket will appear stating your installation was successful.
Django Quick Start: How to stop running the server
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-C.
To stop running the server, return to the CLI and enter the command Ctrl + C.
Django Quick Start: Next Steps
Congratulations, you now have a Django project installed on your computer!
From here, you need to configure your web app to display your custom templates.
Follow us@ordinarycoders