Reader small image

You're reading from  Building SPAs with Django and HTML Over the Wire

Product typeBook
Published inAug 2022
PublisherPackt
ISBN-139781803240190
Edition1st Edition
Tools
Right arrow
Author (1)
Andros Fenollosa
Andros Fenollosa
author image
Andros Fenollosa

Andros Fenollosa is a custom programming expert that works as a teacher, full stack developer, and mobile developer. He's a Web Designer, Web Programmer, and Apps Programmer, among other things ( PWA, Android and iOS ). He has a plethora of commercial expertise, having worked on projects in a variety of locales throughout the world.
Read more about Andros Fenollosa

Right arrow

Preface

HTML over WebSockets simplifies the creation of single-page applications (SPAs) by avoiding frontend rendering, giving real-time responses, and simplifying the logic by moving it to the backend. In this book, you won't learn how to use a JavaScript rendering framework such as React, Vue, or Angular, instead moving the logic to Python. This will simplify your developments, giving you real-time results with all the tools provided by Django.

Developers will learn state-of-the-art WebSockets techniques to realize real-time applications with minimal reliance on JavaScript. They will also learn, from the ground up, how to create a project with Docker, test it, and deploy it on a server.

You will follow the roadmap of a Django developer who wants to create SPAs with a good experience. You will create a project and add Docker, development libraries, Django channels, and bidirectional communication, and then you will create real projects of all kinds using HTML over WebSockets, such as a chat app or a blog with real-time comments. You will modernize your development techniques by moving from using an SSR model to creating web pages using HTML over WebSockets. With Django, you will create SPAs with professional real-time projects where the logic will be in Python.

By the end of the book, you will be able to make real-time applications and will have mastered WebSockets with Django.

Who this book is for

This book is for intermediate-level Django developers and Python web developers who wish to create real-time websites with HTML and Django channels. If you are a developer looking for an alternative to creating an API without giving up the possibility of separating the frontend from the backend and do not want to depend on JavaScript to make SPAs, then this book is for you. Basic knowledge of HTML and Python along with an understanding of basic web development concepts is expected.

What this book covers

Chapter 1, Setting up the Virtual Environment, is where we prepare the IDE and Docker to be able to work with Python.

Chapter 2, Creating a Django Project around Docker, is where we create a project in Django and test it with different Docker containers.

Chapter 3, Adding WebSockets to Django, is where we integrate a WebSockets server into Django via Channels and then test that it can send and receive data.

Chapter 4, Working with the Database, is where we create a microblogging application where we interact with a database performing elementary actions, such as querying, filtering, updating, or deleting.

Chapter 5, Separating Communication in Rooms, is where we learn how to separate communication by users or groups by creating a chat application with private messages and groups.

Chapter 6, Creating SPAs on the Backends, is where we will integrate solutions for the typical problems you may encounter when building a SPA, such as integrating a server-side rendering system per route or hydration sections.

Chapter 7, Creating a Real-Time Blog Using Only Django, helps you use all the knowledge acquired to build a complete SPA blog in real time.

Chapter 8, Simplifying the Frontend, covers simplifying the interaction with client events by integrating Stimulus into the frontend.

To get the most out of this book

You will need a version of Docker and Docker Compose (or Docker Desktop, which includes everything) installed on your computer in the latest version and a code editor or IDE. I recommend PyCharm Professional. All code samples have been tested using Docker on macOS and Linux operating systems; however, they should also work without a problem on Windows.

You will need the professional version of PyCharm to have Docker integration. Otherwise, you can start Docker from the terminal or with Docker Desktop.

If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Building-SPAs-with-Django-and-HTML-Over-the-Wire. If there’s an update to the code, it will be updated in the GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/2q526.

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The information from the frontend goes to receive_json, which in turn receives the 'text in capital letters' action by executing the self.send_uppercase(data) function."

A block of code is set as follows:

* {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    box-sizing: border-box;
}

Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: "At the moment, the Edit and Delete buttons are for decoration; later, we will give them their functionality."

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, email us at customercare@packtpub.com and mention the book title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Share Your Thoughts

Once you’ve read Real-Time Django over the Wire, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Building SPAs with Django and HTML Over the Wire
Published in: Aug 2022Publisher: PacktISBN-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.
undefined
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 $15.99/month. Cancel anytime

Author (1)

author image
Andros Fenollosa

Andros Fenollosa is a custom programming expert that works as a teacher, full stack developer, and mobile developer. He's a Web Designer, Web Programmer, and Apps Programmer, among other things ( PWA, Android and iOS ). He has a plethora of commercial expertise, having worked on projects in a variety of locales throughout the world.
Read more about Andros Fenollosa