Beginners Guide For Django(Web Framework)

Django is a free and open-source web framework, written in Python, which follows the model-view-template (MVT) architectural pattern. It is maintained by the Django Software Foundation (DSF). Django's primary goal is to ease the creation of complex, database-driven websites. Django emphasizes reusability and "pluggability" of components, rapid development, and the principle of Don't Repeat Yourself(DRY). Django is available under the ​BSD license. The source code repository is stored on ​GitHub.

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source. Django was designed to help developers take applications from concept to completion as quickly as possible. Django takes security seriously and helps developers avoid many common security mistakes. Some of the busiest sites on the Web leverage Django’s ability to quickly and flexibly scale.

Django Installation Steps:
1. Get Python installed.
2. Install Pip.
3. Open Terminal and type > sudo pip install django OR Follow This.
4. Check Django version to see if its installed correctly. Type > django-admin --version

Creating First Project in Django
1. Create a directory where you will keep all of your Django Projects.
2. cd to that directory and type > django-admin startproject MySite (here MySite is project name). MySite directory is just a container for your project.
Now. your directory structure will be like
3. Now Start an app inside the project directory by typing > python startapp myapp(this command will create the directory of the app with name myapp)
Directory structure for myapp will be like
    migrations/ file tells Python that this directory is be considered as a Python package. This is an empty file.
4. To see something on the web browser open up the  file in any code editor(i will suggest you PyCharm) and write the below code in it.

from django.http import HttpResponse
def index(request):
            return HttpResponse("Hello, Welcome to Django. You created your first app successfully, congratulations to you.")

5. Now open up the  file in MySite directory and write the below code in it.

from django.conf.urls import url
from django.contrib import admin
from polls import views

urlpatterns = [
            url(r'^$', views.index, name='index'),

6. Now to run the server type > python runserver(this command will start the server and gives you the url of your app like "Starting development server at")  click on the url and you will see your apps first page.

Note: after running python runserver you might get something on terminal which will say the you have few unapplied migration(s). Your project may not work properly until you apply the migrations for app(s). Run 'python migrate' to apply them. So ignore that for now you can learn that later when you will write some advanced apps for projects. Because it is related to all database creation and tables creation.

7. You can also runserver on different ip and port by typing
python runserver OR python runserver 8080

Here i have an app, you can see it. This app has the task of uploading and downloading files, and saving the data into MySQL database.


Popular posts from this blog

"Remotely Bypass" Pattern Lock Of Android Device By Google

WinHex...Data Recovery and Forensics Tool

Crack Gmail and LinkedIn Account Using Brute Force Attack With Simple Python Script

Learn How To Decompile an APK File And Add Some Of Our Own Code To That APK. A Demo Of Decompiling Twitter APK To Get Twitter Username & Passwoed

Complete guide to learn Ethical Hacking