Building Websites with Django
eBook - ePub

Building Websites with Django

Build and Deploy Professional Websites with Python Programming and the Django Framework (English Edition)

Awanish Ranjan

  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

Building Websites with Django

Build and Deploy Professional Websites with Python Programming and the Django Framework (English Edition)

Awanish Ranjan

Book details
Book preview
Table of contents
Citations

About This Book

A beginner's guide that will help you get familiar with Django for web development. Key Features

  • Learn to build websites with a strong blend of concepts and practical learning.
  • Set up your public website with advanced functionalities from scratch.
  • Explore Django architecture, components, navigation panel and templates.

Description
'Building Websites with Django' book teaches readers to develop their high-quality, feature-rich website by learning Django and its various tools. You will learn the best techniques to develop a dynamic website, right from scratch. This book focuses not only on just creating a particular application but rather develops a strong understanding of theoretical concepts with rich examples. You will learn to troubleshoot errors, develop navigation panels and add advanced functionalities like deploying on heroku server. You will read about models, templates, different types of views. You will learn to create apps and learn how to integrate different apps.
By the end of this book, You will create a project from scratch and will deploy it as a public website by yourself. What you will learn

  • Create a Django project from scratch and deploy them as a public website.
  • Work with Django components such as Model, View, and Template.
  • Interact with the database using Query Sets.
  • Deploy your Django application for free on Heroku.
  • Learn how to use Django's built-in authentication and authorization module effectively.

Who this book is for
This book is for early entrepreneurs, beginners, software professionals, bloggers and hobbyists who want to create their online presence on their own without having any prior technical knowledge about web tools. Table of Contents
1. Introduction to Django
2. An Overview of the MTV Architecture
3. Understanding Django Settings
4. Django Admin Utility
5. Interacting with the Database using Query Sets
6. Enhancing your Project
7. Understanding Models
8. Django Views
9. Django Templates
10. URL and Regex
11. Forms in Django
12. Setting up a Project
13. The Account app
14. The Genre app
15. The Post app
16. Deploying the Website

About the Author
After completing his engineering in 2015, Awanish started working with one of the largest IT companies.
He began with scripting and then developed ETL tools and web applications using Django. He is now working on a Content Management System based on Django CMS.In his free time, Awanish delivers guest lectures at training institutes and develops training videos for e-learning sites. LinkedIn Profile: https://www.linkedin.com/in/awanishranjan/

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Building Websites with Django an online PDF/ePUB?
Yes, you can access Building Websites with Django by Awanish Ranjan in PDF and/or ePUB format, as well as other popular books in Informatique & Programmation Web. We have over one million books available in our catalogue for you to explore.

Information

Year
2021
ISBN
9789389328288

CHAPTER 1

What is Django?

Introduction

Python is one of the most versatile programming languages used in the industry today. Because of Python’s simplicity, a programmer gets to focus more on the solution to the problem than on the solution to be implemented. Since it is open-source, we have a huge collection of free and open-source libraries, frameworks, modules, etc. available to use. Django is one of them. Before moving forward, you must have an understanding of frameworks and what Django can offer so that the outcomes match your expectations.
In short, Django is a framework build on Python and it is used for web application development. It is available for free and is open source. You will learn about the basic concepts of a framework. You will know what a framework is and see how Django provides a solution to your web application development requirements.

Structure

  • What is a framework?
  • Why do we need a web framework?
  • What are some famous web frameworks?
  • Is learning Django worth it?
  • What is a virtual environment?
  • How to create and use a virtual environment?
  • How to install Django?
  • How to create a Django project?
  • Overview of your Django project files

Objectives

  • Understanding the concept of frameworks.
  • Understanding the need for frameworks.
  • Familiarizing with the benefits of Django.
  • Understanding the concept of virtual environments.
  • Learning to install Django.
  • Creating a Django project
  • Understanding of the file system of Django

Django overview

Django is famous for its ability to create web applications rapidly. How does this happen? Django has inbuilt middleware and other stuff needed to run a web application. All you need to do is focus on your application. Django very elegantly provides the settings and connections in a configurable manner. You can simply create your applications and configure their settings as per your requirement and you are good to go.
Django was developed in 2003 by web developers at Lawrence Journal-World newspaper, Adrian Holovaty, and Simon Willison. It was released publicly under a BSD license in July 2005. The framework is named after the guitarist Django Reinhardt. Now, the Django Software Foundation has been maintaining Django. This official website for Django is https://www.djangoproject.com/. This is where you can get all the latest updates about Django.
The best thing about Django is that it is very elegantly documented. It is easy to learn and implement. You can find the latest documentation at https://docs.djangoproject.com/en/2.2/. Currently, as of September 2019, Django 2.2 is the latest version. The other widely used version is Django 1.8. I would recommend that you stick to the latest version.

What is a framework?

Let us suppose you have a simple task of drawing a square of side measuring 5cm. You can take your instruments, measure 5cms, and draw your square. Now, if you are asked to draw 1000 such squares, will you follow the same process, not likely? You would create a square frame of the given measurements and use that frame to draw the 1000 squares.
A software framework is very similar to this. Software development has seen a significant history and the requirements of a kind of software are pretty much the same. In a nutshell, a web application needs authentication and authorization, homepage, database connectivity, HTML pages for frontend, CSS for styling, a URL mapper, and a controller to choose what action is to be performed based on the request, etc.
These needs of a software developer or in this case, a web application developer has been identified and the setup has been created (like the frame in the squares example) where a web app developer can easily configure the settings (like the measurements in the squares example) and get the job done quickly and with ease.

Why do we need a framework?

The understanding of the framework makes it pretty much clear why we use frameworks. Let’s quantify the advantages of using a framework:
  • It sets an industry-recognized software design structure. If every developer uses different designs, then it becomes difficult for the software owner or the client to maintain the software once the initial developer leaves the project. Thus, using a framework ensures that a standard design is followed.
  • Re-writing code for common functionalities that are already available in frameworks does not make sense. Also, frameworks allow us to modify the functionalities as per our needs. So, customization is easy.
  • The frameworks have been present for quite some time and extensively tested by developers worldwide, issues are reported, and bug fixes are continuously rolled. This ensures the software is bug-free.
  • The frameworks keep updating with new features as the technology advances. Using a framework keeps your software updated. If you choose not to use a framework, then it becomes the developer’s responsibility to keep the software updated with the latest technology advancements.
Now, you are acquainted with what frameworks are and why we use it. Let’s take a look at what web frameworks are available in the market exception.

What are some famous web frameworks?

Apart from Django, there are several other web application frameworks available in the industry which you should be aware of which are as follows:
  • Flask: Flask is a web application framework written in Python. Flask is based on the WSGI toolkit and Jinja2 template engine.
  • Ruby on Rails: Ruby on Rails is a productive web application framework based on Ruby. One can develop an application at least quite faster with Rails than a typical Java framework.
  • Angular: Angular is a framework on JavaScript by Google which helps us in building powerful web apps. It is a framework to build large scale and high-performance web applications while keeping them as easy-to-maintain.
  • ASP.NET: ASP.NET is a framework developed by Microsoft, which helps us to build robust web applications for PCs, as well as mobile devices. It is a high-performance and lightweight framework for building web applications using .NET.
  • Spring: Spring is the most popular application development framework for enterprise Java. Developers around the globe use Spring to create high-performance and robust web apps.
  • PLAY: Play is one of the modern web application frameworks written in Java and Scala. It follows the MVC architecture and aims to optimize the developer’s productivity by using convention over configuration, hot code reloading, and display of errors in the browser.
Other frameworks worth mentioning are Laravel, Symfony, CodeIgniter, Express, React.js, Node.js, Hibernate, etc.

Is learning Django worth it?

Before you dive into Django and dedicate your time and effort to it, you should ask if it’s worth it. Is it used in industry? You will be glad to know that some of the most famous websites use Django. Examples: Disqus, Instagram, Knight Foundation, MacArthur Foundation, Mozilla, National Geographic, Open Knowledge Foundation, Pinterest, Open Stack, etc. So yes, learning Django is completely worth it. The best part is the more learn, the more it grows over you.

What is a virtual environment?

While developing software or web applications, you will be using a lot of pre-written code legally available from different sources. These sets of code are called libraries, packages, add-ons, plugins, etc. If you are using a framework, then that framework will also have a huge set of pre-written code which will help you implement different features in your application. To use these pre-written codes, you will need to install the libraries, plugins, etc. in your project/application.
The catch here is that different applications are expected to have different features. So, to implement those different features, you will need different set of frameworks, libraries, add-ons, plugins, etc.
Let’s assume you are developing two different applications on your personal computer. Project 1 is using Django 2.1, Python 3.5, bootstrap 4, etc. Whereas Project 2 is using Flask, Python 2.7, bootstrap 3, etc. Now, you have...

Table of contents

Citation styles for Building Websites with Django

APA 6 Citation

Ranjan, A. (2021). Building Websites with Django ([edition unavailable]). BPB Publications. Retrieved from https://www.perlego.com/book/2660983/building-websites-with-django-build-and-deploy-professional-websites-with-python-programming-and-the-django-framework-english-edition-pdf (Original work published 2021)

Chicago Citation

Ranjan, Awanish. (2021) 2021. Building Websites with Django. [Edition unavailable]. BPB Publications. https://www.perlego.com/book/2660983/building-websites-with-django-build-and-deploy-professional-websites-with-python-programming-and-the-django-framework-english-edition-pdf.

Harvard Citation

Ranjan, A. (2021) Building Websites with Django. [edition unavailable]. BPB Publications. Available at: https://www.perlego.com/book/2660983/building-websites-with-django-build-and-deploy-professional-websites-with-python-programming-and-the-django-framework-english-edition-pdf (Accessed: 15 October 2022).

MLA 7 Citation

Ranjan, Awanish. Building Websites with Django. [edition unavailable]. BPB Publications, 2021. Web. 15 Oct. 2022.