How to Create a Django Project in 5 Minutes

It’s incredibly easy to start developing in Django

Steps to Get Started with Django

For the Visual Learners

1.1 Virtual Environment

$ pyenv virtualenv django-tutorialLooking in links: /tmp/tmpjizkdypnRequirement already satisfied: setuptools in /home/bennett/.pyenv/versions/3.6.8/envs/django-tutorial/lib/python3.6/site-packages (40.6.2)Requirement already satisfied: pip in /home/bennett/.pyenv/versions/3.6.8/envs/django-tutorial/lib/python3.6/site-packages (18.1)$ pyenv local django-tutorial

1.2 Install Django

$ pip install django
$ django-admin startproject mysite
$ ls
mysite/
$ cd mysite/
$ ls
manage.py* mysite/
$ python manage.py runserverWatching for file changes with StatReloader
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.
May 17, 2019 - 16:09:28
Django version 2.2.1, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

1.3 Create app

$ python manage.py startapp myapp
$ ls
db.sqlite3 manage.py* myapp/ mysite/

1.4 Register the myapp app with the mysite project

INSTALLED_APPS = [
'myapp.apps.MyappConfig',
... # Leave all the other INSTALLED_APPS
]

1.5 Migrate the database

$ python manage.py migrate

Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying sessions.0001_initial... OK

1.6 Create Super User

$ python manage.py createsuperuserUsername (leave blank to use 'bennett'): 
Email address: hello@bennettgarner.com
Password:
Password (again):
Superuser created successfully.
$ python manage.py runserver

We did it!

Top writer in Technology | Backend Web Developer | bennettgarner.com

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store