Setting up a Django Project
Hi Guys, today we will be learning about how to set up a Django Project but before that let me give you a short overview of what that is. Django is a Widely used Web framework When it comes to Python web development. Django has may default features that makes it the best framework in Python but the most tricky part is the installation of Django so today we will be covering that. So let’s get started.
In order to setup Django, first, you need to download it. You can download Django from their Official Website.
Next step is to download Python3 cause Django is a Python Framework.
Windows Users can go to the Python Official Site and download the .exe file from there.
Linux Users can use below command’s to set it up
$ sudo apt-get update
$ sudo apt-get install python3.6
Mac Users can first download brew from this link
$ brew install python@3.X
Below commands that show how to install Django
$ pip3 install virtualenv
$ virtualenv MY_django_project
$ source venv/bin/activate
(MY_django_project)$ cd MY_django_project
(MY_django_project)$ pip3 install django
Create the Project
With below commands, you can create a project in Django
(MY_django_project)$django-admin startproject My_project
Create the App
Now we will create an app
(MY_django_project)$ cd My_project
(MY_django_project)$ django-admin startapp my_app
Now we will create a database for this. So Django already have an SQLite database setup we just need to migrate models into that
(MY_django_project)$python3 manage.py makemigrations
(MY_django_project)$ Python3 manage.py migrate
Create a Super User
Now we need to create a superuser who can access the Django Admin area
(MY_django_project)$ python manage.py createsuperuser
Email address: firstname.lastname@example.org
Password (again): *********
Superuser created successfully.
then just start the dev server
(MY_django_project)$ python manage.py runserver
and that’s it. This is how you set up a Django Project in just a few minutes. Please try to configure it and let us know in case you face any problem. I would be more than happy to assist you.
You can read my other python posts as well. Like