Build a Book Collection REST API
Build a full CRUD REST API for books using Django REST Framework.
Introduction
30 Second Summary
Every time you browse a library catalog online or check a book's availability, there is an API handling those requests behind the scenes. APIs are the invisible bridges that let applications talk to databases and each other.
In this project, you will build a Book Collection REST API from scratch using Django and Django REST Framework. You will create endpoints that manage books, test them in Postman, and push your finished code to GitHub.
What You'll Build
You will send requests from Postman and watch your API respond with real book data as JSON, proving each endpoint works end to end.
By the end of this project, you'll have:
- A working API where you send a POST request and see a new book appear in your collection.
- Full CRUD functionality: retrieve any book by its ID, update its details, or delete it entirely.
- A tested, complete project on GitHub, ready to share or submit.
- Secret Mission: Add search and ordering filters so users can find books by title or author and sort results.
Are there any prerequisites?
This project assumes basic Python knowledge: variables, functions, and classes. You do not need prior experience with Django or web frameworks.
Before We Start
Before you write any code, take a moment to commit to what you are building and why it matters for your submission.
Set Up Your Environment
Building a REST API requires a few tools working together. Before you can write any API code, you need an isolated Python environment where Django and its packages live separately from your system Python.
In this step, you'll create a project folder, set up a virtual environment, install Django and Django REST Framework, and scaffold the project structure. By the end, you'll have a running Django server proving everything is wired up correctly.
In this step, get ready to:
- Create a project folder with an isolated virtual environment.
- Install Django and Django REST Framework.
- Scaffold the Django project and books app, then confirm the server runs.
Create your project folder and virtual environment
A virtual environment keeps your project's Python packages isolated from the rest of your system. This prevents version conflicts between projects.
- In VS Code, open the integrated terminal by pressing Ctrl+` (macOS) or Ctrl+` (Windows).
- Move to your Desktop by running this command:
cd ~/Desktop
- Create your project folder and move into it by running these commands:
mkdir bookproject
cd bookproject
- Create the virtual environment by running:
python -m venv venv
- Confirm the virtual environment folder was created by running:
ls
You should see a venv folder listed in the output.
- Activate the virtual environment by running the command for your operating system:
macOS
source venv/bin/activate
Windows
venv\Scripts\activate
Your terminal prompt now starts with (venv), confirming the virtual environment is active.
Don't see (venv) in your prompt?
Make sure you ran the activation command for your operating system. macOS uses source venv/bin/activate while Windows uses venv\Scripts\activate.
On Windows, if you see a permissions error, run this command first, then try activating again:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
Help me activate my Python virtual environment.
Install Django and Django REST Framework
Django is the web framework that handles routing, databases, and server logic. Django REST Framework adds tools for building APIs on top of Django.
- Install Django by running:
pip install django==5.2.17
- Install Django REST Framework by running:
pip install djangorestframework==3.17.1
You should see Successfully installed messages for both packages.
Seeing a pip error?
If you see a permissions error, make sure your virtual environment is active. Your prompt should start with (venv). If it doesn't, go back and run the activation command for your OS.
If you see a network error, check your internet connection and try running the command again.
Help me fix my pip install error.
Create the Django project and books app
Django organizes code into a project (the overall configuration) and apps (individual features). You'll create both now.
- Scaffold the Django project in your current folder by running:
django-admin startproject bookproject .
What does the dot at the end do?
The trailing . tells Django to create the project files in your current directory instead of making a nested folder. This keeps your file structure flat and clean.
- Create the books app by running:
python manage.py startapp books
- Confirm both were created by running:
ls
You should see manage.py, a bookproject/ folder, and a books/ folder in the output.
What did these commands create?
- manage.py is your project's command-line tool for running the server, creating migrations, and more.
- bookproject/ holds the project configuration files like settings.py and urls.py.
- books/ is your app folder where you'll build the Book model, views, and serializers.
- Open bookproject/settings.py in VS Code by clicking on it in the Explorer sidebar.
- Find the INSTALLED_APPS list and replace it with the following:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'books',
]
What did you add?
- 'rest_framework' registers Django REST Framework so it can provide API tools like serializers and browsable views.
- 'books' tells Django about your new app so it can find its models, views, and URL patterns.
- Save bookproject/settings.py.
✔️ Awesome, I've got everything!
Great. Double check you've saved bookproject/settings.py before moving on.
ⓧ I'd like to double check the full code
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'books',
]
Before you run the next command, what do you think you'll see when you start the Django development server for the first time?
- Start the development server by running:
python manage.py runserver
The server takes over your terminal. You'll see output including the URL http://127.0.0.1:8000/.
Seeing a warning about unapplied migrations?
You may see a message saying you have unapplied migrations. This is completely normal. The server still runs fine. You'll apply those migrations in the next step.
- Open your browser and visit http://127.0.0.1:8000/.
You should see Django's default welcome page with a green rocket graphic. This confirms Django is installed correctly and your project is configured.
Keep the server running
Leave the server running in this terminal. When you need to run another command later, press Ctrl+C to stop the server first, or open a new terminal with Ctrl+Shift+`.
Don't see the rocket page?
Make sure you saved bookproject/settings.py before running the server. If you edited the wrong list or have a typo, Django won't recognize the installed apps.
Check the terminal for error messages. A common issue is a missing comma between items in INSTALLED_APPS.
Help me fix my Django development server.
Your environment is ready. Next up, you'll define the Book model and store your first book in the database.
Create the Book Model
Your Django project is running, but it has nothing to serve yet. Before you can build an API, you need to define what a "Book" looks like in your database.
Django uses models to map Python classes to database tables. In this step, you'll create a Book model, store it in the database, and add a sample book through Django's built-in admin panel.
In this step, get ready to:
- Define the Book model and run migrations to create the database table.
- Register the model in the admin panel and add sample data.
Define the Book model
Each Django model becomes a database table. The fields you define on the model become columns in that table.
- Stop the running development server by pressing Ctrl+C in your terminal.
- Open books/models.py in VS Code and replace its contents with the following code:
from django.db import models
class Book(models.Model):
# Each field becomes a column in the database table
title = models.CharField(max_length=200)
author = models.CharField(max_length=200)
isbn = models.CharField(max_length=13, unique=True)
published_date = models.DateField()
def __str__(self):
return self.title
What does this code do?
The Book class inherits from models.Model, which tells Django to create a database table for it.
- title and author are text fields limited to 200 characters.
- isbn is a 13-character text field with unique=True so no two books can share the same ISBN.
- published_date stores a calendar date.
- __str__ controls how the book displays its name in the admin panel and shell.
- Save books/models.py.
- Create the migration file by running this command:
python manage.py makemigrations
You should see output mentioning Create model Book and a new migration file under books/migrations/.
- Apply the migration to create the actual database table by running:
python manage.py migrate
You should see several lines ending with OK, confirming the tables were created in your SQLite database.
Seeing an error about no changes detected?
Make sure you saved books/models.py before running the command.
Also confirm that 'books' is listed in INSTALLED_APPS inside bookproject/settings.py. Django only detects models from registered apps.
help me fix my Django makemigrations command
✔️ Awesome, I've got everything!
Great. Double check you've saved books/models.py and that both migration commands ran without errors.
ⓧ I'd like to double check the full code
from django.db import models
class Book(models.Model):
# Each field becomes a column in the database table
title = models.CharField(max_length=200)
author = models.CharField(max_length=200)
isbn = models.CharField(max_length=13, unique=True)
published_date = models.DateField()
def __str__(self):
return self.title
Register the model in admin and add sample data
Django ships with a built-in admin panel that lets you manage database records through a web interface. You need to register your Book model so it appears there.
- Open books/admin.py in VS Code and replace its contents with:
from django.contrib import admin
from .models import Book
# Register Book so it shows up in the admin panel
admin.site.register(Book)
What does this code do?
admin.site.register(Book) tells Django to add the Book model to the admin interface. Without this line, your Book table exists in the database but has no admin UI.
- Save books/admin.py.
Now you need a superuser account to log into the admin panel. The createsuperuser command will ask you for a username, email, and password.
- Create your admin account by running:
python manage.py createsuperuser
What prompts will I see?
Django will ask for three things in order:
- Username (pick anything, like admin).
- Email (you can press Enter to leave it blank).
- Password (type it twice to confirm). The characters won't appear on screen as you type. If Django warns the password is too common, type y to bypass the warning.
- Start the development server again by running:
python manage.py runserver
- Open your browser and visit http://127.0.0.1:8000/admin/.
- Log in with the username and password you just created.
- Click Books in the admin dashboard.
- Click Add Book in the top right corner.
- Fill in the fields with these values:
- Title: Django for Beginners
- Author: William Vincent
- Isbn: 9781735467221
- Published date: 2024-06-01
- Click Save.
Before you check the result, what do you expect to see when you click Books in the sidebar now?
- Click Books in the left sidebar.
You should see Django for Beginners listed in the table. The __str__ method you defined is what makes the book's title appear here instead of a generic "Book object" label.
Don't see Books in the admin?
Make sure you saved books/admin.py before starting the server. If the server was already running when you saved, stop it with Ctrl+C and start it again with python manage.py runserver.
help me get the Books model showing in Django admin
✔️ Awesome, I've got everything!
Great. Make sure books/admin.py is saved and your book is visible in the admin list.
ⓧ I'd like to double check the full code
from django.contrib import admin
from .models import Book
admin.site.register(Book)
Your database has a Book table with real data in it. Next up, you'll build an API layer so external clients can access your books over HTTP without needing the admin panel.
Build the API Endpoints
Right now, the book you added lives inside Django's admin panel. Only someone with a superuser login can see it.
External clients like Postman or a frontend app need a way to access your book data over HTTP. In this step, you will build an API layer that exposes your books to the outside world.
In this step, get ready to:
- Create a serializer that converts Book model instances to JSON.
- Build a list/create API view and wire up URL routing.
- Discover a gap in your API by testing a URL that does not exist yet.
Create the serializer
A serializer translates your Django model instances into JSON (and back again). Without one, DRF has no way to turn a Book database row into the JSON response a client expects.
- In VS Code, create a new file called serializers.py inside the books folder.
- Add the following code to books/serializers.py:
from rest_framework import serializers
from .models import Book
# Converts Book model instances to/from JSON
class BookSerializer(serializers.ModelSerializer):
class Meta:
model = Book
fields = '__all__'
What does this code do?
- ModelSerializer automatically generates serializer fields that match the fields on your Book model.
- fields = '__all__' tells DRF to include every field (id, title, author, isbn, published_date) in the JSON output.
- Save books/serializers.py. The BookList view you build next imports this serializer to turn database rows into JSON responses.
✔️ Awesome, I've got everything!
Great. Make sure you saved the file before moving on.
ⓧ I'd like to double check the full code
from rest_framework import serializers
from .models import Book
class BookSerializer(serializers.ModelSerializer):
class Meta:
model = Book
fields = '__all__'
Create the list/create view and wire up URLs
DRF's generic views give you ready-made logic for common API patterns. You provide a queryset and a serializer, and the view handles GET (list) and POST (create) for you.
- Open books/views.py in VS Code. Replace any existing content with the following code:
from rest_framework import generics
from .models import Book
from .serializers import BookSerializer
# Handles GET (list all books) and POST (create a new book)
class BookList(generics.ListCreateAPIView):
queryset = Book.objects.all()
serializer_class = BookSerializer
What does this code do?
- ListCreateAPIView provides get and post method handlers. GET returns a list of all books. POST creates a new book.
- queryset tells the view which database records to serve.
- serializer_class tells the view how to convert those records to JSON.
- Save books/views.py.
- Create a new file called urls.py inside the books folder. Add the following code:
from django.urls import path
from . import views
# Maps the /books/ URL to the BookList view
urlpatterns = [
path('books/', views.BookList.as_view(), name='book-list'),
]
What does this code do?
- path('books/', ...) maps the URL path books/ to your BookList view.
- .as_view() converts the class-based view into a callable that Django's URL dispatcher can use.
- name='book-list' gives this URL pattern a name you can reference elsewhere in the project.
- Save books/urls.py.
- Open bookproject/urls.py (the project-level URL file, not the one you just created). Replace its content with:
from django.contrib import admin
from django.urls import path, include
# Connect the books app URLs under the /api/ prefix
urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('books.urls')),
]
What does this code do?
- include('books.urls') pulls in all URL patterns from your books app.
- The 'api/' prefix means the full URL becomes http://127.0.0.1:8000/api/books/.
- Save bookproject/urls.py.
- In your browser, visit http://127.0.0.1:8000/api/books/.
You should see the DRF browsable API page with your book listed in JSON format and a form at the bottom to create new books.
Seeing a Page not found error?
- Check that your Django server is still running in the terminal. If it stopped, run python manage.py runserver again.
- Make sure bookproject/urls.py uses include('books.urls') and not a direct view reference.
- Confirm that books/urls.py is in the books folder (not in bookproject).
- Help me debug my DRF browsable API not loading.
✔️ Awesome, I've got everything!
Great. Double check you saved all three files before continuing.
ⓧ I'd like to double check the full code
Here is each file you created or edited in this substep:
from rest_framework import generics
from .models import Book
from .serializers import BookSerializer
class BookList(generics.ListCreateAPIView):
queryset = Book.objects.all()
serializer_class = BookSerializer
from django.urls import path
from . import views
urlpatterns = [
path('books/', views.BookList.as_view(), name='book-list'),
]
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('books.urls')),
]
Test the partial API
Your API can now list all books and create new ones. But what happens when you try to access a single book by its ID?
- Before you try this, predict: do you think visiting http://127.0.0.1:8000/api/books/1/ will show book #1, or will it fail?
- In your browser, visit http://127.0.0.1:8000/api/books/1/.
You see a Page not found (404) error. This is expected and intentional.
Why does this happen?
Your books/urls.py only has one URL pattern: books/. There is no pattern for books/1/ or books/<int:pk>/.
You can list and create books, but you cannot retrieve, update, or delete a specific book. The next step adds the missing detail endpoint to complete your CRUD operations.
Your API is live and serving data. Next up, you will add the missing detail endpoint so clients can retrieve, update, and delete individual books.
Complete the CRUD
In the previous step, you built list and create endpoints and discovered a gap. Visiting http://127.0.0.1:8000/api/books/1/ returned a 404 error because your API has no way to handle requests for a single book.
That missing detail endpoint means half of CRUD is gone. Users can list and create books, but they cannot retrieve, update, or delete a specific one. This step closes that gap.
In this step, get ready to:
- Add a detail view for single-book operations.
- Wire up the detail URL pattern to complete CRUD.
Add the detail view
Django REST Framework provides a generic view called RetrieveUpdateDestroyAPIView that handles GET, PUT, PATCH, and DELETE for a single model instance. It pairs with the ListCreateAPIView you already have to give you the full set of CRUD operations.
- Open books/views.py and add this class below the existing BookList class:
# View for retrieving, updating, and deleting a single book
class BookDetail(generics.RetrieveUpdateDestroyAPIView):
queryset = Book.objects.all()
serializer_class = BookSerializer
What does this code do?
RetrieveUpdateDestroyAPIView automatically provides get, put, patch, and delete method handlers for a single model instance.
It uses the same queryset and serializer_class pattern as your BookList view. DRF looks up the specific book by its primary key from the URL.
- Save books/views.py.
✔️ Awesome, I've got everything!
Great. Make sure you saved the file before moving on.
ⓧ I'd like to double check the full code
Here is the complete books/views.py at this point:
from rest_framework import generics
from .models import Book
from .serializers import BookSerializer
class BookList(generics.ListCreateAPIView):
queryset = Book.objects.all()
serializer_class = BookSerializer
class BookDetail(generics.RetrieveUpdateDestroyAPIView):
queryset = Book.objects.all()
serializer_class = BookSerializer
Add the detail URL pattern
The view exists, but Django does not know which URL should trigger it. You need a URL pattern that captures the book's ID from the request path and routes it to BookDetail.
- Open books/urls.py and find the existing urlpatterns list:
urlpatterns = [
path('books/', views.BookList.as_view(), name='book-list'),
]
- Add the following line inside the urlpatterns list, directly after the first path entry:
# Route for single-book operations using the book's primary key
path('books/<int:pk>/', views.BookDetail.as_view(), name='book-detail'),
What does <int:pk> mean?
<int:pk> is a URL path converter. It captures an integer from the URL (like the 1 in /api/books/1/) and passes it to the view as pk (primary key).
DRF's generic view uses that pk to look up the exact book in the database.
- Save books/urls.py.
✔️ Awesome, I've got everything!
Great. Make sure you saved the file before moving on.
ⓧ I'd like to double check the full code
Here is the complete books/urls.py at this point:
from django.urls import path
from . import views
urlpatterns = [
path('books/', views.BookList.as_view(), name='book-list'),
path('books/<int:pk>/', views.BookDetail.as_view(), name='book-detail'),
]
Before you refresh, what do you expect to see at http://127.0.0.1:8000/api/books/1/ now that you have both the view and the URL pattern in place?
- Refresh http://127.0.0.1:8000/api/books/1/ in your browser.
You should see the single book's details displayed in the browsable API, with PUT, PATCH, and DELETE options available. The 404 is gone.
Still seeing a 404?
- Make sure the book with ID 1 still exists. If you deleted it through the admin panel, try /api/books/2/ or whichever ID your book has.
- Check that the new path line is inside the urlpatterns list (between the square brackets), not outside it.
- Confirm you saved both books/views.py and books/urls.py. Django's dev server auto-reloads on save, but unsaved changes are invisible.
Help me debug my 404 on the book detail endpoint
Your API now has full CRUD capability. Next up, you will test every endpoint in Postman and push the complete project to GitHub.
Test in Postman and Push to GitHub
Your API works in the browser's browsable interface, but your assignment needs two more deliverables: tested endpoints in Postman and a GitHub repository.
In this step, you'll install Postman to test all five CRUD operations with real HTTP requests. Then you'll push your complete project to GitHub so it's ready to submit.
In this step, get ready to:
- Test all five API endpoints in Postman.
- Push the complete project to GitHub with a clean repository.
Install Postman and test all CRUD operations
Postman is a dedicated tool for sending HTTP requests to APIs. Unlike the browser's browsable API, Postman lets you craft precise requests with custom headers, bodies, and methods.
- Download Postman from https://www.postman.com/downloads/ and run the installer for your operating system.
- After installation completes, Postman opens automatically. Create a free account or sign in when prompted.
Postman not opening after install?
Press Cmd+Space (macOS) or the Windows key (Windows) to open your search bar, type Postman, and press Enter.
Help me troubleshoot Postman not opening
Your Django server should still be running from the previous step. If you stopped it, start it again before testing.
- In Postman, click the + button to open a new request tab.
- Leave the method as GET.
- Enter http://127.0.0.1:8000/api/books/ in the URL field.
- Click Send.
You should see a JSON array in the response body containing the book(s) you added earlier through the admin panel.
What does this response tell you?
A 200 OK status code means the server successfully returned your data. The response body is a JSON array because the list endpoint returns all books in the collection.
Now test creating a new book with a POST request.
- Click the + button to open another new request tab.
- Click the method dropdown and select POST.
- Enter http://127.0.0.1:8000/api/books/ in the URL field.
- Click the Body tab below the URL field.
- Select the raw radio button.
- Click the format dropdown to the right and select JSON.
- Paste the following JSON into the body editor:
{
"title": "Django for Beginners",
"author": "William S. Vincent",
"isbn": "9781735467221",
"published_date": "2022-01-01"
}
- Click Send.
You should see a 201 Created status code and the newly created book object in the response, including its assigned id.
Seeing a 400 Bad Request?
Double-check that you selected raw and JSON in the Body tab. If the format is set to Text, Postman won't send the correct Content-Type header and Django will reject the request.
Also confirm your JSON has no trailing commas and all field names match the model exactly: title, author, isbn, published_date.
Help me fix my 400 Bad Request error
Next, test retrieving a single book. Note the id value from the POST response you just received.
- Open a new request tab with the + button.
- Leave the method as GET.
- Enter http://127.0.0.1:8000/api/books/1/ in the URL field (replace 1 with the ID from your POST response if different).
- Click Send.
You should see a 200 OK response with a single book object instead of an array.
Now test updating that book with a PUT request.
- Open a new request tab.
- Click the method dropdown and select PUT.
- Enter http://127.0.0.1:8000/api/books/1/ in the URL field.
- Click the Body tab, select raw and JSON.
- Paste the following JSON:
{
"title": "Django for Beginners",
"author": "William S. Vincent",
"isbn": "9781735467221",
"published_date": "2022-05-01"
}
- Click Send.
You should see a 200 OK response with the updated published_date now showing 2022-05-01.
Finally, test deleting a book.
- Open a new request tab.
- Click the method dropdown and select DELETE.
- Enter http://127.0.0.1:8000/api/books/1/ in the URL field.
- Click Send.
You should see a 204 No Content status code with an empty response body. The book has been removed from your database.
Why 204 and not 200?
A 204 No Content response means the server processed the request successfully but has nothing to send back. The book is gone, so there is no object to return.
Push to GitHub
With all endpoints verified, the last deliverable is pushing your project to a GitHub repository. First you need to create a .gitignore file to keep generated files out of version control.
- Stop the Django server by pressing Ctrl+C in your VS Code terminal.
- Create a new file called .gitignore in your bookproject folder (the top-level folder that contains manage.py) and add the following content:
venv/
db.sqlite3
__pycache__/
*.pyc
.env
What does this file do?
The .gitignore file tells Git which files to exclude from version control. Your virtual environment (venv/), local database (db.sqlite3), and Python cache files don't belong in a repository.
- Save .gitignore.
Now create a new repository on GitHub to push your code to.
- Open github.com in your browser and sign in.
- Click the + icon in the top-right corner and select New repository.
- Enter a repository name (for example, book-collection-api).
- Leave the repository as Public.
- Do NOT check any of the initialization options (no README, no .gitignore, no license). You already have your own files.
- Click Create repository.
- Copy the HTTPS URL shown on the next page. It looks like https://github.com/YOUR-USERNAME/YOUR-REPO-NAME.git.
- Initialize your local Git repository and make your first commit by running these commands:
git init
git add .
git commit -m "Book Collection REST API with Django REST Framework"
What do these commands do?
- git init creates a new Git repository in your project folder.
- git add . stages all files (except those in .gitignore) for commit.
- git commit saves a snapshot of your staged files with a descriptive message.
You should see output listing the files that were committed. The venv/ folder and db.sqlite3 should NOT appear in that list.
Seeing venv files in the commit?
Make sure your .gitignore file is saved and located in the same folder as manage.py. If venv/ was already staged, run git rm -r --cached venv/ to unstage it, then commit again.
Help me fix venv being tracked by Git
- Push your code to GitHub by running these commands:
git branch -M main
git remote add origin [[GITHUB_REPO_URL="https://github.com/YOUR-USERNAME/YOUR-REPO-NAME.git"]]
git push -u origin main
What do these commands do?
- git branch -M main renames your default branch to main.
- git remote add origin connects your local repository to the GitHub repository you just created.
- git push -u origin main uploads all your committed files to GitHub.
Authentication error when pushing?
GitHub no longer accepts passwords for command-line access. If prompted for credentials, you need a Personal Access Token or to authenticate via the GitHub CLI. Follow the instructions GitHub shows in the error message.
Help me fix my GitHub authentication error
Before you check GitHub, what do you expect to see in the repository? Do you think every file from your project made it there, or might something be missing?
- Refresh your GitHub repository page in the browser.
You should see your project files listed: bookproject/, books/, manage.py, and .gitignore. The venv/ folder and db.sqlite3 file should NOT be there.
✔️ Awesome, I've got everything!
Great. Double check you've saved all files and your GitHub repository shows the complete project.
ⓧ I'd like to double check the full code
The only new file created in this step is .gitignore. Here is its complete content:
venv/
db.sqlite3
__pycache__/
*.pyc
.env
All other project files (books/views.py, books/urls.py, books/models.py, books/serializers.py, books/admin.py, bookproject/settings.py, bookproject/urls.py) remain unchanged from the previous step.
You've tested every endpoint and shipped your code. Your Book Collection REST API is complete, verified, and ready to submit.
Secret mission
Add Search and Ordering Filters
Your API works, but imagine you have hundreds of books in your collection. Users would need to scroll through every single one to find what they want. Can you add search and ordering so they can find books instantly?
Clean Up Your Resources
Clean Up Your Resources
This project runs entirely on your local machine, so there are no ongoing cloud costs. Decide whether to keep your resources running, pause them to come back later, or delete them entirely.
Resources you used:
- The bookproject folder (includes virtual environment, database, and all source code).
- GitHub repository with your pushed code.
- Postman desktop app (installed during this project).
Keep everything running
No action needed. Choose this if you are still actively building or want to extend the project further.
- Your Django server stays available whenever you activate the virtual environment and run python manage.py runserver.
- Your Postman requests are saved in your account and ready to reuse.
- Your GitHub repository remains accessible at your URL.
Pause - I'll come back to this later
Stop the running server to free up your terminal. Your files and data stay on disk for later.
- Press Ctrl+C in the terminal running your Django server to stop it.
- Close the VS Code window for the project.
- When you come back, open the bookproject folder in VS Code, activate the virtual environment, and run python manage.py runserver to pick up where you left off.
Delete - I don't want to use this again
Remove all project files, the GitHub repository, and Postman from your machine.
- Stop the Django server by pressing Ctrl+C in the terminal.
- Navigate to the Desktop (or whichever folder contains bookproject) and delete the project folder.
macOS
cd ~/Desktop
rm -rf bookproject
Windows
cd ~\Desktop
rmdir /s /q bookproject
- Delete your GitHub repository by following these steps.
- Open your repository page on GitHub.
- Click Settings.
- Scroll down to the Danger Zone section.
- Click Delete this repository.
- Click I want to delete this repository.
- Click I have read and understand these effects.
- Type your repository name to confirm, then click Delete this repository.
- Uninstall Postman from your machine.
macOS
- Open Finder and go to Applications.
- Drag Postman to the Trash.
- Empty the Trash to complete the removal.
Windows
- Open Settings.
- Select Apps, then Installed apps.
- Find Postman in the list and click Uninstall.
That's a Wrap!
That's a Wrap!
Nice work! You just built a complete REST API from scratch using Django and Django REST Framework, tested every endpoint in Postman, and shipped the whole thing to GitHub.
You've learned how to:
- Built a Django project from scratch with a Book model and database, defining fields, running migrations, and managing data through the admin panel.
- Created a full REST API with separate CRUD endpoints using DRF's generic views, experiencing firsthand how list and detail views map to different HTTP methods.
- Tested all five API operations (GET list, POST, GET single, PUT, DELETE) in Postman and pushed the complete project to GitHub, ready to submit.
- Secret Mission: Added search and ordering filters so users can find books by title or author and sort results, making the API production-ready.
Ready to quiz yourself?