Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building SPAs with Django and HTML Over the Wire

You're reading from   Building SPAs with Django and HTML Over the Wire Learn to build real-time single page applications with Python

Arrow left icon
Product type Paperback
Published in Aug 2022
Publisher Packt
ISBN-13 9781803240190
Length 264 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Andros Fenollosa Andros Fenollosa
Author Profile Icon Andros Fenollosa
Andros Fenollosa
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Part 1: Getting Started with Python
2. Chapter 1: Setting up the Virtual Environment FREE CHAPTER 3. Chapter 2: Creating a Django Project around Docker 4. Part 2: WebSockets in Django
5. Chapter 3: Adding WebSockets to Django 6. Chapter 4: Working with the Database 7. Chapter 5: Separating Communication in Rooms 8. Part 3: HTML over WebSockets
9. Chapter 6: Creating SPAs on the Backends 10. Chapter 7: Creating a Real-Time Blog Using Only Django 11. Part 4: Simplifying the frontend with Stimulus
12. Chapter 8: Simplifying the Frontend 13. Other Books You May Enjoy

Chapter 1: Setting up the Virtual Environment

A good programmer is not afraid of technology because their confidence doesn’t lie in the programming language, but in their own skills and experience. Tools only make them more productive. We can’t build even the simplest website in an acceptable amount of time without the right software. Building websites with Python is possible on any modern operating system, regardless of the hardware behind it. The core team that maintains this fantastic language already takes care of some of the more tedious tasks, such as compiling it and optimizing it for the processor you’re using.

However, building a web application in Python, even if we only respond with plain text, requires a great deal of knowledge, including of servers and web applications as well as the WSGI or ASGI interface. We need to abstract that complexity to respond to requests, environments, asynchrony, WebSocket, database connections, and the other elements that define a current web application. That’s why we’re going to set up a desktop with everything you need to be a productive modern Django developer. We will build different real-time applications using the technology offered by Channels, a Django extension (developed by the same Django team), which includes a WebSocket server and WebSocket integrations. The architecture of the applications will differ from how server-side rendering works. The communication path between the server and the client will be bidirectional, allowing us to use it to receive or send events and/or HTML. My intention is that upon finishing the chapter, your focus will be on the code and not on complex configurations that may distract you. To achieve this, we will make use of Docker, the famous container manager, which will open up the possibility of adding all kinds of software already precooked to launch without investing practically any time: databases, web servers, mail servers, and caches, among others. Don’t worry if you have no experience with Docker. I’ll teach you the basics without going into low-level details. After a few tweaks, you’ll practically forget that it’s running in the background.

It’s important not only that we know how to write Python and create real-time infrastructures with Django but also that we have the skills to be independent of the operating system when deploying or working in a team. By virtualizing (or isolating) the processes, we can remain unconcerned about the operating system where it runs, making the project easy to continue for any specialist, and we can anticipate future problems that may occur when deploying to a production server.

In this chapter, we’ll be covering the following topics:

  • Exploring the software required
  • Adding dependencies
  • Configuring the IDE
  • Installing Django
  • Creating our project
You have been reading a chapter from
Building SPAs with Django and HTML Over the Wire
Published in: Aug 2022
Publisher: Packt
ISBN-13: 9781803240190
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime