Django and Python

Django Tutorial: Building a Basic Web App Using Django Python

Brief Intro

In this guide, you will learn about employing an MVC web framework for a basic web app, which is written in Python. Python is a powerful and popular programming language. This text is a Django tutorial that gives emphasis to utilizing Django and Python to create a web application in the cloud with many common features found in today’s Web 2.0 applications.
By the end of this post, you will appreciate the benefits of using Python and Django. When combined, both become powerful tools of the trade for rapid development of dynamic web applications.

What is Python

Python is a general-purpose programming language. It is used for a wide variety of applications and is very suitable for developing web applications. Python has a clean and elegant syntax, and is supported by a large library of standard and contributed modules, which covers everything from multi-threading to the zipping of files. Notably, the language’s object-oriented model is especially suited for MVC style development.

What is Django

Django is an open-source web framework written in Python that enables you to build clean and feature-rich web applications with minimal time and effort. Moreover, it loosely follows a model-view-controller design pattern, which greatly helps in building clean and maintainable web applications.

Read Also: How to Make a Blog with Django

What is a Basic Django Web App

Django is a highly developed framework that is very efficient at handling Web Application development and backend requirements.

Here, the front end of our web app has a clean UI that makes it very accessible to the user. Following is a sample screenshot of the app flow.

A basic web app to demonstrate for our Django tutorial

Advantages of Django for Python

Since the spread of the MVC pattern into web development, Python has provided quite a few choices when it comes to web frameworks. Examples include Django, TurboGears, and Zope. Thus, Django is one of the available frameworks for Python and provides the following advantages over other frameworks.

  • a) Tight Integration between Components
  • b) Object-Relational Mapper
  • c) Clean URL Design
  • d) Automatic Administration Interface
  • e) Advanced Development
  • f) Multi-Lingual Support

Django Tutorial Overview

In this tutorial, we are trying to explore the project with respect to system requirement specification (SRS) and system design specification (SDS).

SRS

  • a) Intended Audience
  • b) Pre-requisites

SDS

  • a) Software requirements
  • b) Use Cases
  • c) Implementation of test projects
  • d) Limitation and future enhancements

Final Project

The Project Final Report concisely summarizes the outcomes of a project and is the final document in the Project Management Methodology. Therefore, a Project Final Report documents project performance. This template outlines the content and format of final reports for all information systems projects.

Django GitHub Project

You can access the Django Github project using this Link to Django Source Code. Open this link to get the Github project repository.

First of all, in order to Django source code locally, you need to create a Python 3.5 virtualenv and then install the following dependencies.

# pip install -r requirements/dev.txt
# npm install

Afterwards, make a directory to put the project’s data like MEDIA_ROOT, DOC_BUILDS_ROOT, etc in it. Then create a ‘secrets.json’ file in a directory named ‘conf’ in your user’s home directory as shown below.

{ "secret_key": "xyz",
"superfeedr_creds": ["[email protected]", "any_string"],
"db_host": "localhost",
"db_password": "password",
"trac_db_host": "localhost",
"trac_db_password": "password" }

Next, you need to create its new database and access to the new users on that database and then you will be able to populate the www and docs hostnames in the django.contrib.sites app. Execute the following script.

# ./manage.py loaddata dev_sites

For docs use the command.

# ./manage.py loaddata doc_releases
# ./manage.py update_docs

For dashboard run the following commands to load the latest dashboard categories and metrics.

# ./manage.py loaddata dashboard_production_metrics

Django Tutorial – Web App Conclusion

In this article, we completed a Django tutorial developing a basic web app using Django Python. Regardless of where you decide to host a Django app, the thought process behind developing this project is to provide hands-on for developers interested in building web apps using Django and Python.

Click Here to Deploy a Django VPS

Share this post with your friends