DJANGO- a web framework of python(part-3) final blog of this series
first blog of the series is here : https://codexmaze.blogspot.com/2019/05/django-web-frame-work-of-python.html
As we all know that django has a set pattern of design. That is the reason it is more effective and most used now a days .This is going to be a short blog . in this blog i am going to introduce set pattern of Django in initial phases.STEP 1:
CREATE A PROJECT -- open powershell and type command :
" python django-admin startproject projectname"
STEP 2:
CREATE AN APP - I already declared the difference betwen apps and projects in first part of this series . For starting an app inside a project type command :
AT first go under the same directory as of your project --
$ cd c://user/desktop/projectname
Now start an app --
$ python manage.py startapp appname
now you will get an directory with appname with some predefined an organised classes
STEP 3: NOW go to "settings.py " section and and go to "INSTALLED APPS " section add your app their with format --
"appname.apps.AppnameConfig "
If you are working with REST framework then add --
"rest_framework"
STEP 4: THEN go to "models.py " section on your app . Basically this is a database section if you have been used mysql then you will know that we have to create tables using structured language.
In models.py we also are creating data fields in django way .
STEP 5: NOW we will go to "admin.py " section of app and register our model (the name of the class)there which is basically similar to table name in phpmyadmin .
for registering the model write --
"admin.site.register(class-name)" class name is basically table name in database .
Step 6: now go to "views.py " section and design your view. VIEW are the things that specify that what will we see on typing a specific url .
So this is most important section which you really need to understand . In view.py section we design that what will we get on typing a URL .
STEP 7: NOW go to "urls.py "section and in "urlpattern" add your "url" and specify path from "views.py" as you have to import views from appname , then forward your url to that view .
So basically in "urls.py" you have to add a pattern or specify a path in which you have to write the url and the page or view(basically a class of views.py ) to which it will redirect.
So these are the initial and basic steps in Django development which you need to understand . Hope the series of django will help you in getting started and understand basics.
STEP 8: I need to specify this step step before but that won't make a differnce as you are at initial level . Django comes with a default server so you don't need to setup a database for django.
just type command inside your project directory on powershell --
$ python manage.py runserver
and you will got a view like this on powershell screnn :
and when you will type that url(http://127.0.0.1:8000/)on your browser you will see the default django page , which is previously setup , with a official documentation note you can see things from there when you got stuck .
Blog on django REST API is here :https://codexmaze.blogspot.com/2019/06/django-web-framework-rest-api-part-2.html you can check it out .
Comments
Python Online Training in Hyderabad
Python Institute in Hyderabad
Python Course in Hyderabad
Web Design and Development Company in India
Python Online Training
Mean Stack Training in Chennai
React JS Training in Chennai