I had heard about Django framework 5 to 6 month ago, my friends used it to create various API's , beautiful website and other various stuff. At the time I was learning Laravel frameowrk and was improving my python skills. I learnt Laravel without the prior knowledge in PHP, I did manage to make a social media clone however the logic writing there was bit difficult. On top of that my interest recently grew in machine learning and data science. So couple of weeks ago I quit learning laravel, and decided that i wanted to master Django.
One of the main reason I got interested in Django was this ability to create sub groups, which Django calls 'apps' , and it allowed various work to be distributed in various apps . For example if we create an E commerce website, we could create app to handle users and other apps to handle shops. This allows the code to be very distributed and easy to understand. There were other various benefits , one major one for me personally was that it was completely in python which i am very handy with.
About a week ago i started learning Django basics. Django works in MVT( Model View Template ) format. The model is a component that handles the Database. We can create a model by using python class. The view is the component where you write the logic, and template is the website that is rendered.
To start django , we will first need to install the Django package,
I recommend you start by creating python virtual environment
python -m virtualenv {virtual_env_name} will create a virtual environment for you
pip install django will install the Django package in your virtual environment
to create your first django project we can used django-admin command ,
django-admin createproject {Project_Name} this will create a folder with your project name
and inside there you will find a one very important file called settings.py
To run the server , we can just type the following ,
python manage.py runserver
By default your server will run in localhost:8000, or you can also specify the port you want to use
Congratulation you just created your first Django project
Comments
Post a Comment