Django Startup Sequence
Tags: python, django, beginners
Published: 2019-04-22 15:47:12

*Originally posted on https://highceburg.tech.blog*

# Initializing project directory, installing the virtual environment and django:

<pre>mkdir _project_name_
cd project_name
virtualenv _dir_name_
. ./_dir_name_/bin/activate
python -m pip install django
</pre>

To test if the installation worked, inside the virtual environment command prompt, start the interactive interpreter by typing

<pre>python</pre>

If the installation is successful, you should be able to import the django module and check the what version was installed:

<pre>Python 3.10.0 (default, Oct 14 2021, 20:54:55) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
</pre>

<pre>>>> import django
>>> django.get_version()
'3.2.8'
>>> 
</pre>

Exit interpreter once done.

# Starting a project:

<pre>django-admin startproject _app_name_ </pre>

# Creating a Database:

Inside the created folder in the last step, run the following command:

<pre>python -m manage migrate
</pre>

This creates a sqlite database and any necessary database tables. If all goes well, this is what you'll see:

<pre>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
</pre>

# The Development Server:

To verify the migration, run:

<pre>python -m manage runserver
</pre>

You will see the following output on the command line:

<pre>Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
April 22, 2019 - 15:24:21
Django version 2.2, using settings 'app.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
</pre>

That's all folks!

###### Reference:

###### [Build your first website with Python and Django: Build and Deploy a website with Python & Django](https://amzn.to/2IypHGB)

[![](//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&MarketPlace=US&ASIN=0994616864&ServiceVersion=20070822&ID=AsinImage&WS=1&Format=_SL250_&tag=vagr888-20)](https://www.amazon.com/gp/product/0994616864/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0994616864&linkCode=as2&tag=vagr888-20&linkId=fcc76125667c318f3ab0f253eb86ff5d)![](//ir-na.amazon-adsystem.com/e/ir?t=vagr888-20&l=am2&o=1&a=0994616864)