Django Tutorials for Beginner to Advanced - Part 1 - Technic Hubs

Technic Hubs

Technic Hubs aims in providing hands-on experience on Machine Learning, Augmented Reality(AR), Virtual Reality(VR), Django(Web Development), Flutter and React(App Development), Internet of Things(IoT) with videos on Nepali.

Breaking

Thursday, November 9, 2017

Django Tutorials for Beginner to Advanced - Part 1

Django is the one of very famous web development framework in Python Programming Language. You should have basic programming knowledge of python for this. Lets begin our tutorial from zero. Django works on MVT pattern where M is Model, V is View and T is Template. But not like other MVC, where C is Control, all the controls are managed by Django itself. Leaving us to manage only the templates. So its great to learn work smartly.

Installation of Django

Intially, you should have python in your computer. Then you can type:
                                     pip install django
Now, you are ready for your first Django project. To check either your django is installed or not.You can type:
                                     django-admin --version

 

First Django Project 

To start your first django project you have to type:
                                     django-admin startproject mysite
Here mysite can be any of your project name. After executing this line of code you will have a directory including:
                                     mysite/
                                              manage.py
                                              mysite/
                                                         (Actual Project File)


If you open mysite you can see:

Django tutorials 










here, __init__.py defines that this is a python package.
         settings.py contains all settings of project.

         urls.py contains the actual contents on the website. 
         wsgi.py contains all server management processes.
We will discuss all of them in later. But we are not going to touch __init__.py

Lets begin then:
After successfully execution of django-admin startproject mysite we will have a directory as shown above. 
1. __init__.py is a blank page that reminds us only that this is a python package.
2. settings.py is a file which contains all of our project settings. like database management, password validation and so on over here.
3.  urls.py stores all the url patterns of your project. Basically different pages link of your web application
4.  wsgi.py this is Web Server Gateway Interface. This helps to deploy our project in server.
5. manage.py associates with many of the command we associate with this project.
Lets use manage.py to make our server. For this type:
                      python manage.py runserver
then open your browser @http//:127.0.0.1:8000/.

Congrats, you are ready now. Now we will begin our website in next tutorial.


Please do comment for any how to do problems. I will try to be as responsive as possible. 
                                          

No comments:

Post a Comment