Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorDaniel Correa, Greg Lim

In this book, we take you on a fun, hands-on and pragmatic journey to learning Django API React stack development. You'll start building your first Django API React stack app within minutes. Every chapter is written in a bite-sized manner and straight to the point as we don’t want to waste your time (and most certainly ours) on the content you don't need. In the end, you will have the skills to create a Todo app and deploy it to the Internet. In the course of this book, we will cover Chapter 1: Introduction Chapter 2: Installing Python and Django Chapter 3: Understanding the Project Structure Chapter 4: Creating Our Backend Server Chapter 5: Serialization Chapter 6: URLs and Class-based Views Chapter 7: Creating Todos via the ListCreateAPIView Chapter 8: Permissions Chapter 9: Other C.R.U.D. Operations Chapter 10: Completing a Todo Chapter 11: Authentication – Sign Up Chapter 12: Authentication – Log In Tokens Chapter 13: Introduction to React Chapter 14: Create Navigation Header Bar Chapter 15: Defining Our Routes Chapter 16: TodoDataService - Connecting to the Backend Chapter 17: TodoDataService - Login Component Chapter 18: TodosList Component Chapter 19: Adding and Editing Todos Chapter 20: Deleting a Todo Chapter 21: Completing a Todo Chapter 22: Deployment Chapter 23: Hosting and Deploying our React Frontend The goal of this book is to teach you Django API React stack development in a manageable way without overwhelming you. We focus only on the essentials and cover the material in a hands-on practice manner for you to code along. Working Through This Book This book is purposely broken down into short chapters where the development process of each chapter will center on different essential topics. The book takes a practical hands on approach to learning through practice. You learn best when you code along with the examples in the book. Requirements No previous knowledge on Django or React development is required, but you should have basic programming kno

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# Beginning Django API with React — Reading Guide ## 【One-Line Pitch】 A hands-on, bite-sized tutorial that takes you from zero to a deployed full-stack Todo app using Django REST Framework for the backend and React for the frontend — ideal for beginners who want to learn by building rather than reading theory. ## 【Book Arc】 - **Opening (~0%–9%)**: Introduces the book's philosophy of practical, concise learning; explains why APIs matter (serving multiple frontends like iOS, Android, React) and what Django REST Framework (DRF) offers — CRUD operations, authentication, serializers, and routing with minimal code. - **Early (~9%–25%)**: Covers environment setup — installing Python/Django, creating the `backend` project, understanding Django's project structure (`manage.py`, `settings.py`, `urls.py`, `wsgi.py`), and creating the `todo` app with its first model. - **Early (~25%–34%)**: Walks through migrations (`makemigrations`/`migrate`), setting up the admin site with a superuser, registering the Todo model, and creating the first serializer to control which fields are exposed in the API. - **Middle (~34%–47%)**: Implements API endpoints using DRF's generic class-based views — `ListAPIView` for read-only lists, `ListCreateAPIView` for read-write, and `RetrieveUpdateDestroyAPIView` for full CRUD on individual todos, plus custom logic for completing a todo. - **Late (~47%–75%)**: Adds authentication — user sign-up and token-based login — then transitions to the frontend: introducing React, building a navigation header, defining routes, and creating a `TodoDataService` to connect React to the Django API. - **Ending (~75%–100%)**: Builds out the remaining React components (login, todos list, add/edit/delete/complete todo) and finishes with deployment — hosting both the Django backend and React frontend on the internet. ## 【Key Takeaways】 - **APIs decouple backend from frontend** (Opening): Building a REST API with DRF lets one codebase serve multiple clients (web, iOS, Android), making apps more scalable and maintainable than traditional server-rendered Django. - **DRF's generic views eliminate boilerplate** (Middle): Using `ListCreateAPIView` and `RetrieveUpdateDestroyAPIView` gives you working CRUD endpoints with just a serializer class and queryset — no need to reinvent the wheel. - **Serializers control API exposure** (Early): By specifying fields in a serializer, you decide exactly what data is visible in the API; read-only fields like `created` and `completed` prevent users from manipulating auto-populated values. - **Permissions and queryset filtering secure user data** (Middle): Setting `permission_classes = [IsAuthenticated]` and filtering querysets by `request.user` ensures users can only access and modify their own todos. - **Custom actions extend generic views** (Middle): For non-CRUD logic like completing a todo, you can add custom URL paths (e.g., `todos/<int:pk>/complete`) and override methods — DRF's hooks let you inject logic before database operations. - **Token authentication enables API login** (Late): The book shows how to implement sign-up and token-based login so React can authenticate users and make authorized API requests. - **React connects to APIs via service layers** (Late): A dedicated `TodoDataService` component handles API calls from React, keeping the frontend organized and making it easy to manage requests to the Django backend. ## 【Reading Tips】 - **Skim Chapters 2–3 if you know Django basics**: The project structure explanation is standard; focus instead on the DRF-specific parts (serializers, generic views) starting around Chapter 5. - **Code along with every example**: The book is deliberately hands-on — you'll learn far more by typing each command and modifying each file than by reading passively. - **Pay special attention to Chapters 6–9**: This is where the core API patterns are established; understanding generic views and queryset filtering here will make the rest of the book smooth sailing. - **Don't skip the deployment chapters (22–23)**: Even if you're not deploying immediately, these chapters clarify how the backend and frontend fit together in production. - **If you hit a wall with React**: The React half assumes basic JavaScript knowledge; consider reviewing React fundamentals separately if the component patterns feel unfamiliar. ## 【Coverage Limits】 Excerpts cover the Django backend thoroughly (setup through authentication) and outline the React frontend structure, but detailed React component code and deployment specifics are only partially represented in the source material. ##
Page 4
a practical hands on approach to learning through practice. You learn best when you code along with the examples in the book. Requirements No previous knowle...
View in text
Page 9
Both files are used when deploying our app. We will revisit them later when we deploy our app. urls.py This is the file which tells Django which pages to ren...
View in text
Page 15
rk. Installation Install DRF using pip: Execute in Terminal pip3 install djangorestframework Next, add 'rest_framework' to your INSTALLED_APPS setting in ../...
View in text
Excerpt 4
ete own posts return Todo.objects.filter(user=user) Like the ListCreateAPIView, RetrieveUpdateDestroyAPIView requires two mandatory attributes which are seri...
View in text
Excerpt 5
.save() token = Token.objects.create(user=user) return JsonResponse({'token':str(token)},status=201) except IntegrityError: return JsonResponse( {'error':'us...
View in text
Excerpt 6
bVitals from './reportWebVitals'; It then renders App with: Analyze Code ReactDOM.render( <React.StrictMode> <App /> React-Router-DOM We will next install re...
View in text
Excerpt 7
ate. When we pass null to useState, i.e. useState(null), we specify null to be the initial value for user. useState returns an array with two values: the cur...
View in text
Excerpt 8
ername); setError(''); .catch( e =>{ console.log('login', e); setError(e.toString()); } * Contact support@i-ducate.com for the source code if you prefer to c...
View in text
Tags
AI categories
PythonBackendCloud Native
ISBN: 8416644020
Publisher: Independent
Publish Year: 2022
Language: English
Pages: 138
File Format: PDF
File Size: 3.0 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…