Django can be installed using pip. Let’s install the dependencies for Django
pip – Python package manager
sqlite3 – Basic database backend for Django
py27-sqlite3 – Python2.7 library for sqlite3
pkg install python pkg install py27-pip pkg install sqlite3 pkg install py27-sqlite3
Now that we have installed the dependencies, let’s install Django using the following command:
pip install django
We can check the version of Python, Sqlite3 and Django
python --version sqlite --version python -c "import django; print(django.get_version())"
We can now generate the project using the following command. This file will create a folder named myproject and will generate necessary files needed for the Django app to work.
django-admin.py startproject myproject
The settings can be edited using the file named settings.py inside the project folder we just created. The default settings use sqlite as the database backend.
We can check the settings by run this command.
cd myproject python manage.py migrate
The server can be started using the command
python manage.py runserver
The command above, starts Django listening on 127.0.0.1:8000. If we want Django to listen on specific port on all interfaces, we can use the following command
python manage.py runserver 0.0.0.0:8000