Django is an open-source framework written in python for quickly building web applications. Django includes user authentication, content management, sites maps, and several other features by default to make it easier and faster for developers to build their applications. In this article, we will show you how to install a Django.
Installing Django on Ubuntu
- First you will need to install some python packages and PIP3.
sudo apt install python3-pip python-dev libmysqlclient-dev
Ubuntu assumes python 2.7 currently so we should make sure the command “pip” uses python 3 by running the command below.
ln -s /usr/bin/pip3 /usr/bin/pip pip install mysql-python virtualenv
- Next you need to create a virtual environment for your project, The purpose of this is to isolate the packages used by this project to prevent any other packages installed for other projects from causing conflicts.
cd ~ virtualenv django1
- Now enter the virtual environment and install django.
source ~/django1/bin/activate pip install django
- Now that you have Django installed you can create your project.
django-admin startproject project1
Now that you have created the project run the commands below and follow the prompts to create your admin user for the Django dashboard.
python manage.py migrate python manage.py createsuperuser python manage.py runserver 0.0.0.0:8000
You should now be able to go to https://<yourIP>:8000 and you should see a page saying “It Worked, Congratulations on your first Django-powered page”. You can view your dashboard going to https://<yourIP>:8000/admin and logging in with the credentials created before.
Congratulations! You now have Django installed.