Decoupled Django: Understand and Build Decoupled Django Architectures for JavaScript Front-ends
Book information
Description
Apply decoupling patterns, properly test a decoupled project, and integrate a Django API with React, and Vue.js. This book covers decoupled architectures in Django, with Django REST framework and GraphQL. With practical and simple examples, you’ll see firsthand how, why, and when to decouple a Django project. Starting with an introduction to decoupled architectures versus monoliths, with a strong focus on the modern JavaScript scene, you’ll implement REST and GraphQL APIs with Django, add authentication to a decoupled project, and test the backend. You’ll then review functional testing for JavaScript frontends with Cypress. You will also learn how to integrate GraphQL in a Django project, with a focus on the benefits and drawbacks of this new query language. By the end of this book, you will be able to discern and apply all the different decoupling strategies to any Django project, regardless of its size. What You'll Learn Choose the right approach for decoupling a Django projectBuild REST APIs with Django and a Django REST frameworkIntegrate Vue.js and GraphQL in a Django projectConsume a Django REST API with Next.jsTest decoupled Django projects Who This Book Is For Software developers with basic Django skills keen to learn decoupled architectures with Django. JavaScript developers interested in learning full-stack development and decoupled architectures with Django. Table of Contents About the Author About the Technical Reviewer Acknowledgments Introduction Chapter 1: Introduction to the Decoupled World Monoliths and MVC What Makes a Decoupled Architecture? Why and When to Decouple? Hypermedia All the Things Hypermedia as the Engine Client-Server Separation Stateless Cacheable Uniform Interface An Introduction to GraphQL Summary Additional Resources Chapter 2: JavaScript Meets Django JavaScript and Django in Production The Need for Module Bundlers Webpack Fights Django (the Need for Code Splitting) Modern JavaScript, Babel, and Webpack A Word on TypeScript JavaScript Frontend Libraries and Frameworks Lightweight JavaScript UI Libraries Universal JavaScript Applications Static Site Generators Testing Tooling Other Ancillary JavaScript Tools Summary Additional Resources Chapter 3: Modern Django and the Django REST Framework What Is the Django REST Framework? Class-Based Views in Django and the DRF CRUD Viewsets in DRF Models, Forms, and Serializers From WSGI to ASGI Getting Started with Asynchronous Django Competing Asynchronous Frameworks and the DRF Summary Additional Resource Chapter 4: Advantages and Disadvantages of Decoupled Architectures Pseudo-Decoupled Django Pseudo-Decoupled Without REST Pseudo-Decoupled with REST Fully-Decoupled Django Fully-Decoupled with REST Fully-Decoupled with GraphQL Summary Chapter 5: Setting Up a Django Project Setting Up the Project A Custom User Interlude: Choosing the Right Database Splitting the Settings File Bonus: Running Django Under ASGI Splitting the Requirements File Summary Chapter 6: Decoupled Django with the Django REST Framework Building the Billing App Building the Models Enabling the App Wireframing the Billing App Pseudo-Decoupled with the Django REST Framework Vue.js and Django Building the Vue App Vue.js, Django, and CSS Building the REST Backend Building the Serializers Building the Views and the URL Working with Nested Serializers Fixing the Vue Frontend Summary Additional Resource Chapter 7: API Security and Deployment Django Hardening Django Settings for Production Authentication and Cookies in Django Randomize the Admin URL REST API Hardening HTTPS Encryption and HSTS Audit Logging Cross-Origin Resource Sharing Authentication and Authorization in the DRF Disable the Browsable API Deploying a Decoupled Django Project Preparing the Target Machine Configuring NGINX Gunicorn and Django Production Requirements Preparing Vue.js in Production with Django The Deployment Summary Additional Resource Chapter 8: Django REST Meets Next.js Django as a Headless CMS Building the Blog App Building the Model Enabling the App Building the REST Backend Building the Serializer Building the Views and the URL Introduction to the React Ecosystem A Reintroduction to React Introduction to Next.js Building the Next.js Frontend Pages and Routing Data Fetching Static Site Generation Deploying Next.js Using React with Django The Vue.js Ecosystem Summary Additional Resource Chapter 9: Testing in a Decoupled World Introduction to Functional Testing Getting Started with Cypress Understanding Functional Testing for the Billing App Creating the First Test Filling and Submitting the Form Introduction to Unit Testing Unit Testing in the Django REST Framework Django Settings for Testing Installing the Dependencies and Configuring Requirements for Testing Outlining Tests for the Billing REST API Testing the Billing REST API Summary Additional Resource Chapter 10: Authentication and Authorization in the Django REST Framework Introduction to Token-Based Authentication and JWT Token-Based Authentication: The Good and the Bad JSON Web Tokens in Django: Advantages and Challenges Session-Based Auth for Single-Page Apps Some Words on Production and Development Preparing NGINX for the New Setup Handling the Login Flow with Django Preparing the Vue.js App for the New Setup A Note About HttpOnly Cookies Handling Authentication in the Frontend Authorization and Permissions in the Django REST Framework Summary Additional Resource Chapter 11: GraphQL in Django with Ariadne Getting Started with Ariadne in Django Installing Ariadne Designing the GraphQL Schema Loading the Schema in Ariadne Wiring Up the GraphQL Endpoint Working with Resolvers Using Query Arguments in GraphQL A Word on Schema-First vs Code-First Implementing Mutations Adding a Resolver for the Mutation Introduction to GraphQL Clients Building the React Frontend Getting Started with Apollo Client Creating a Select Component Creating a Form Component Creating the Root Component and Making Queries Using Apollo Hooks for React Summary Additional Resources Chapter 12: GraphQL in Django with Strawberry Getting Started with Strawberry in Django Installing Strawberry Designing the GraphQL Schema in Strawberry Types and Enums in Strawberry Working with Resolvers (Again) Queries in Strawberry and Wiring Up the GraphQL Endpoint Input Types and Mutations in Strawberry Working Asynchronously with the Django ORM Working Again on the Frontend Creating Invoices with a Mutation What’s Next? Summary Additional Resources Index
Similar books
Decoupled Django: Understand and Build Decoupled Django Architectures for JavaScript Front-ends
2021 · EPUB
MySQL® Notes for Professionals book
2018 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
Session C11: Ancient Cultural Landscapes in South Europe – their Ecological Setting and Evolution, Session C22: Gardeners from South America, Session S04: Agro-Pastoralism and Early Metallurgy Sessions, Session WS29: The Idea of Enclosure in Recent Iberian Prehistory, Session C88: Rhytmes et causalites des dynamiques de l'anthropisation en Europe entre 6500 ET 500 BC: Hypotheses socio-culturelles et/ou climatiques: Proceedings of the XV UISPP World Congress (Lisbon 4-9 September 2006) / Actes du XV Congrès Mondial (Lisbonne 4-9 Septembre 2006) Vol.36
2010 · PDF
THE BRITISH ARMY IN INDIA: ITS PRESERVATION BY AN APPROPRIATE CLOTHING, HOUSING, LOCATING, RECREATIVE EMPLOYMENT, AND HOPEFUL ENCOURAGEMENT OF THE TROOPS. with AN APPENDIX ON INDIA : THE CLIMATE OP ITS HILLS ; THE DEVELOPMENT OF ITS RESODRCBS, INDUSTRY, AND ARTS ; THE ADMINISTRATION OF JUSTICE ; THE BLACK ACT ; THE PROGRESS OF CHRISTIANITY ; THE TRAFFIC IN OPIUM ; THE VALUE OF INDIA ; PERMANENT CAUSES OF DISAFFECTION, AND OF THE RECENT REBELLION ; THE TRADITIONARY POLICY; MISGOVERNMENT BY NATIVE RULERS ; ANNEXATIONS OF THEIR TERRITORY, ETC.
1858 · PDF
Idries Shah 27 Books Collection : A Perfumed Scorpion, A Veiled Gazelle, Caravan of Dreams, Darkest England, Destination Mecca, Evenings with Idries Shah, Knowing How to Know, Learning How to Learn, Letters and Lectures of Idries Shah, Neglected aspects of Sufi study, Observations, Oriental Magic, Reflections, Seeker after Truth, Special Illumination, Special Problems in the study of Sufi ideas, Sufi thought and action, Tales of the Dervishes, The Dermis Probe, The Elephant in the Dark, The Englishman Handbook, Idries Shah Antology, The Magic Monastery, The natives are restless, wisdom of the Idiots PDF.
2022 · PDF
The travels of Capts. Lewis and Clarke from St. Louis, by way of the Missouri and Columbia rivers, to the Pacific ocean; performed in the years 1804, 1805 & 1806, by order of the government of the United States. Containing delineations of the manners, customs, religion, &c. of the Indians, comp. from various authentic sources, and original documents, and a summary of the Statistical view of the Indian nations, from the official communication of Meriwether Lewis. Illustrated with a map of the country, inhabited by the western tribes of Indians
1809 · PDF