Build a Book Collection REST API

Build a full CRUD REST API for a book collection using Django.

Introduction

30 Second Summary

Everyone has a list of books they've read, want to read, or keep recommending to friends. What if you could manage that collection through a proper web API that any app or service could talk to?

In this project, you will build a REST API for a book collection using Django and Django REST Framework. You'll create endpoints that support creating, reading, updating, and deleting books, and manage your data through Django's built-in admin panel.

What You'll Build

A fully functional REST API backend powered by Django that exposes CRUD endpoints for managing a personal book collection.

By the end of this project, you'll have:

  • A Django project with a custom app, a data model, and database migrations that create your books table.
  • A REST API with endpoints for listing, creating, retrieving, updating, and deleting books through HTTP requests.
  • A Django admin panel and a browsable API interface for managing and testing your book data through a web browser.
  • Secret Mission: Add filtering and search to your API so users can find books by author or title.

Are there any prerequisites?

You need basic Python knowledge (variables, functions, and classes). No prior Django or web development experience is needed.

Before We Start

Before We Start...

Set Up Your Development Environment

Every web application starts with a solid foundation. Before you write any Django code, you need Python installed, a clean project folder, and an isolated environment where your packages live without conflicting with other projects on your machine.

In this step, you will verify your Python installation, create a virtual environment, and install Django along with Django REST Framework. By the end, you will have a fully scaffolded Django project ready for building.

In this step, get ready to:
  • Verify Python 3.12+ is installed and create a project folder.
  • Install Django and Django REST Framework inside a virtual environment.
  • Scaffold the Django project structure.
Install Python and create a project directory

Django 6.0 requires Python 3.12 or higher. Let's confirm you have the right version before going further.

  • Press Cmd+Space (macOS) or the Windows key (Windows) to open your search bar.
  • Type Terminal (macOS) or PowerShell (Windows) and press Enter to open it.
  • Check your Python version by running this command:

macOS

python3 --version

Windows

python --version

✔️ I see version 3.12 or higher

You should see output like Python 3.12.x or Python 3.13.x. You are good to go.

ⓧ I see an older version

If you see a version lower than 3.12 (for example Python 3.9.x or Python 3.11.x), you need to install a newer version. macOS sometimes ships with an older Python that shadows newer installations.

  • Download Python 3.12 or higher from python.org/downloads.
  • Run the installer and follow the prompts.
  • After installation, close and reopen your terminal, then run the version check again.
  • On macOS, if python3 --version still shows the old version, try python3.12 --version to confirm the new installation is available. Use python3.12 in place of python3 for the rest of this project.

ⓧ Command not found

Python is not installed on your machine yet. Let's install it.

  • Go to python.org/downloads.
  • Download the latest Python 3.12+ installer for your operating system.
  • Run the installer. On Windows, check the box that says Add Python to PATH before clicking Install Now.
  • Close and reopen your terminal after installation.
  • Run the version check command again to confirm it works.

Now let's create a folder to hold your project. All your project files will live here.

  • Move to your Desktop by running this command:
cd ~/Desktop
  • Create your project folder and move into it by running these commands:
mkdir book-collection-api
cd book-collection-api
  • Confirm the folder exists by running:
ls

The folder is empty for now. That is expected.

Next, you need a virtual environment. This isolates your project's packages from anything else installed on your system.

  • Create a virtual environment by running this command:

macOS

python3 -m venv venv

Windows

python -m venv venv

What is a virtual environment?

A virtual environment is an isolated Python installation inside your project folder. Packages you install here stay separate from your system Python.

This prevents version conflicts between different projects. Every professional Python project uses one.

  • Activate your virtual environment by running this command:

macOS

source venv/bin/activate

Windows

venv\Scripts\activate

You should see (venv) appear at the beginning of your terminal prompt. This confirms 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 first: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser and then try activating again.
  • Confirm you are inside the book-collection-api folder. The venv folder must exist in your current directory.

Help me troubleshoot my virtual environment activation.

Install Django and Django REST Framework

With your virtual environment active, any packages you install will stay contained inside this project. Time to install the two main frameworks.

  • Install Django and Django REST Framework by running this command:
pip install django djangorestframework

What are these two packages?

Django is a Python web framework that handles URL routing, database management, and admin interfaces. It gives you the structure for a web application.

Django REST Framework (DRF) is a toolkit built on top of Django that adds everything you need for building APIs. It provides serializers, viewsets, and a browsable API interface.

You should see output showing packages downloading and installing. When it finishes, you will see a Successfully installed message.

  • Verify Django installed correctly by running:
python -m django --version

You should see 6.0.5 printed in your terminal.

Seeing an error or wrong version?

  • Make sure your virtual environment is active. Look for (venv) at the start of your prompt. If it is missing, run the activation command again.
  • If pip was not found, try pip3 install django djangorestframework instead.

Help me fix my Django installation issue.

Create the Django project

Django uses a specific project structure to organize your code. The django-admin command scaffolds this structure for you in one step.

  • Scaffold your Django project by running this command:
django-admin startproject bookshelf .

What does this command do?

django-admin startproject bookshelf . creates a Django project named bookshelf in your current directory. The dot at the end is important.

Without the dot, Django creates a nested folder (bookshelf/bookshelf/) which is confusing. The dot tells Django to use your current book-collection-api folder as the project root.

  • Confirm the project was created by running:
ls

You should see manage.py and a bookshelf/ folder listed in the output (along with venv/).

What are these files?

  • manage.py is your command center. You will use it to run the server, create apps, and manage the database.
  • bookshelf/ is the project configuration folder. It contains settings.py (project settings), urls.py (URL routing), and other configuration files.

Seeing 'command not found' for django-admin?

  • This usually means your virtual environment is not active. Check for (venv) in your prompt and re-activate if needed.
  • If your venv is active but the command still fails, try python -m django startproject bookshelf . as an alternative.

Help me troubleshoot my django-admin command.

Your development environment is ready. Next up, you will create a books app and define the data model that powers your API.

Create the Books App and Model

Your Django project is scaffolded and ready to go. Right now it is an empty shell with no app-specific logic inside it.

In this step, you will create a Django app called books and define the data model that represents a book in your collection. The model tells Django how to create and manage your database table.

In this step, get ready to:
  • Create the books app and register it in your project settings.
  • Define the Book model with fields for title, author, year, ISBN, and description.
  • Run migrations to create the database table.
Create the books app

Django organizes code into apps. Each app handles one area of functionality. Your books app will hold everything related to storing and serving book data.

  • Generate the books app by running this command:
python manage.py startapp books
  • Confirm the app was created by running:
ls books/

You should see __init__.py, admin.py, apps.py, models.py, tests.py, views.py, and a migrations/ folder listed in the output.

Command not found?

Make sure your virtual environment is still activated. You should see the environment name in parentheses at the start of your terminal prompt.

Also confirm you are inside the project directory that contains manage.py.

Help me troubleshoot the startapp command

The app exists on disk, but Django does not know about it yet. You need to register it in the project settings along with Django REST Framework.

  • Open bookshelf/settings.py in your editor.
  • Find the INSTALLED_APPS list.
  • Replace the entire INSTALLED_APPS list with the following code:
INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "rest_framework",
    "books",
]

What does this code do?

INSTALLED_APPS tells Django which apps to load when the project starts. By adding "rest_framework" and "books", Django will now load DRF's functionality and recognize your new books app.

  • Scroll to the bottom of bookshelf/settings.py and add this REST Framework configuration below the last line:
REST_FRAMEWORK = {
    "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
    "PAGE_SIZE": 10,
}

What does this code do?

This dictionary configures how Django REST Framework behaves across your entire project. PAGE_SIZE limits API responses to 10 results per page. This prevents your API from dumping thousands of records in a single response.

  • Save bookshelf/settings.py.

Not sure where to add REST_FRAMEWORK?

Place it at the very end of the file, after all other settings. There should be nothing below it.

Help me find the right place in settings.py

Define the Book model

A model defines the structure of your data. Each field in the model becomes a column in the database table. Django uses this definition to create, query, and validate your data automatically.

  • Open books/models.py in your editor.
  • Replace the entire file contents with the following code:
from django.db import models


class Book(models.Model):
    # Core book information
    title = models.CharField(max_length=200)
    author = models.CharField(max_length=200)
    published_year = models.IntegerField()
    isbn = models.CharField(max_length=13, unique=True)
    description = models.TextField(blank=True)

    # Automatic timestamp for when the book entry was created
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"{self.title} by {self.author}"

    class Meta:
        ordering = ["-created_at"]

What does this code do?

  • CharField stores short text with a maximum length. TextField stores longer text without a limit.
  • unique=True on the isbn field ensures no two books can share the same ISBN.
  • auto_now_add=True automatically records the current date and time when a new book is created.
  • The __str__ method controls how a book appears in the admin panel and terminal output.
  • ordering = ["-created_at"] makes queries return newest books first by default.
  • Save books/models.py.

✔️ Awesome, I've got everything!

Great. Make sure you have saved the file before continuing.

ⓧ I'd like to double check the full code

Here is what your complete books/models.py should look like:

from django.db import models


class Book(models.Model):
    title = models.CharField(max_length=200)
    author = models.CharField(max_length=200)
    published_year = models.IntegerField()
    isbn = models.CharField(max_length=13, unique=True)
    description = models.TextField(blank=True)
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"{self.title} by {self.author}"

    class Meta:
        ordering = ["-created_at"]
Run migrations

Your model is defined in Python, but the database does not have a table for it yet. Migrations are Django's way of translating model changes into database instructions.

  • Generate the migration file by running this command:
python manage.py makemigrations

You should see output indicating that Django created books/migrations/0001_initial.py with a "Create model Book" operation.

What is a migration file?

A migration file is a set of instructions that Django uses to create or change database tables. Think of it as a recipe that Django follows to build the table structure your model describes.

  • Apply the migration to create the actual database table by running:
python manage.py migrate

You should see a series of "Applying..." lines as Django creates tables for both the built-in apps and your new books app.

  • Confirm the database file was created by running:
ls db.sqlite3

You should see db.sqlite3 listed. This is the SQLite database file where all your book data will be stored.

Seeing "No changes detected"?

This means Django cannot find your model. Check that "books" is listed in INSTALLED_APPS in bookshelf/settings.py. Also make sure you saved both settings.py and books/models.py before running the command.

Help me fix my migrations

Your data model is in place and the database table is ready. Next up, you will set up Django admin so you can manage books through a web interface.

Set Up Django Admin

Your Book model is defined and the database table is ready. Now you need a way to actually add and manage book records.

Django ships with a built-in admin panel that gives you a full web interface for managing your data. You register your model, and Django generates the forms, lists, and search features for you.

In this step, get ready to:
  • Create a superuser account for admin access.
  • Register the Book model in the admin interface.
  • Add sample books to test with later.
Create a superuser account

The Django admin panel is password-protected. You need a superuser account to log in.

  • Create your admin account by running this command:
python manage.py createsuperuser

What will this command ask me?

Django will prompt you for a username, email address, and password. Choose any values you like. You will use them to log in to the admin panel shortly.

If you pick a short or common password, Django will warn you and ask if you want to bypass validation. Type y and press Enter to proceed.

  • Follow the prompts in your terminal to set a username, email, and password.

You should see Superuser created successfully. in your terminal output.

Seeing a password validation error?

Django enforces password rules by default. If your password is fewer than 8 characters or too common, Django will reject it. Choose something longer, or type y when asked to bypass validation.

help me fix the createsuperuser password error

Register the Book model in admin

Django's admin panel does not know about your Book model until you explicitly register it. Registration tells the admin which fields to display, which to make searchable, and which to use as filters.

  • Open books/admin.py in your editor and replace its contents with the following code:
from django.contrib import admin

from .models import Book


@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
    # Columns shown in the book list
    list_display = ["title", "author", "published_year", "isbn"]
    # Fields searchable from the admin search bar
    search_fields = ["title", "author"]
    # Sidebar filter for narrowing results by year
    list_filter = ["published_year"]

What does this code do?

The @admin.register(Book) decorator registers your Book model with the admin site. Without this, the admin panel would not show books at all.

The BookAdmin class customizes how books appear. list_display controls which columns show up in the list view. search_fields adds a search bar that filters by title and author. list_filter adds a sidebar that lets you filter by published year.

  • Save books/admin.py.

You will not see a change yet. The next substep starts the server where you will see the admin in action.

Seeing an import error later?

Make sure from .models import Book uses a dot before models. The dot means import from the same package. Without it, Python will not find your model.

help me fix an import error in books/admin.py

✔️ Awesome, I've got everything!

Great. Make sure you have saved books/admin.py before moving on.

ⓧ I'd like to double check the full code

Here is the complete books/admin.py file:

from django.contrib import admin

from .models import Book


@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
    list_display = ["title", "author", "published_year", "isbn"]
    search_fields = ["title", "author"]
    list_filter = ["published_year"]
Add sample books via admin

Time to see your admin panel in action. You will start the development server, log in, and add a couple of books so you have data to work with when you build the API.

  • Start the Django development server by running this command:
python manage.py runserver

What does this command do?

This launches a local web server at http://127.0.0.1:8000/. It will keep running in your terminal until you stop it with Ctrl+C. Leave it running for now.

  • Open your browser and go to http://127.0.0.1:8000/admin/.
  • Enter the username and password you created with createsuperuser.
  • Click Log in.

You should see the Django administration dashboard with a BOOKS section listing Books.

  • Click Books to open the book list.
  • Click Add Book in the top right corner.
  • Fill in the fields for your first book. For example:
  • Title: 1984
  • Author: George Orwell
  • Published year: 1949
  • Isbn: 9780451524935
  • Description: A dystopian novel about totalitarianism.
  • Click Save and add another.
  • Add a second book with different details. For example:
  • Title: To Kill a Mockingbird
  • Author: Harper Lee
  • Published year: 1960
  • Isbn: 9780060935467
  • Description: A novel about racial injustice in the American South.
  • Click Save.

You should now see both books listed in the admin panel with columns for title, author, published year, and ISBN.

Don't see your Books section in admin?

Make sure you saved books/admin.py with the registration code. The development server auto-reloads on save, but if it shows an error in the terminal, check for typos in your file.

Also confirm that "books" is listed in INSTALLED_APPS in bookshelf/settings.py.

help me troubleshoot why my Book model is not showing in Django admin

You now have a working admin panel with sample data. Next up, you will build the REST API that exposes this data as JSON endpoints.

Build the REST API

Your Book model is defined and you have sample data in the database. Now it is time to expose that data as a REST API so any client can create, read, update, and delete books over HTTP.

To turn a Django model into a full API, Django REST Framework uses three layers: a serializer converts model instances to JSON, a viewset handles HTTP requests, and a router generates URL patterns automatically.

In this step, get ready to:
  • Create a serializer to convert Book objects to and from JSON.
  • Create a viewset to handle all CRUD operations.
  • Wire up URL routing so the API is accessible at a real endpoint.
Create the serializer

A serializer defines which model fields appear in API responses and how incoming JSON data maps back to model fields.

  • 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


class BookSerializer(serializers.ModelSerializer):
    class Meta:
        model = Book
        fields = ["id", "title", "author", "published_year", "isbn", "description", "created_at"]
        read_only_fields = ["id", "created_at"]

What does this code do?

ModelSerializer automatically generates serializer fields based on the model you point it to. You just tell it which fields to include.

  • fields lists every field the API will expose in responses and accept in requests.
  • read_only_fields marks id and created_at so clients cannot set them manually. Django handles these automatically.
  • Save books/serializers.py.
  • You will not see a visible change yet. The next chunk connects this serializer to a viewset that handles HTTP requests.
Create the viewset

A viewset groups together the logic for listing, creating, retrieving, updating, and deleting objects. DRF's ModelViewSet gives you all five operations in a single class.

  • Open books/views.py in your editor.
  • Replace its contents with the following code:
from rest_framework import viewsets

from .models import Book
from .serializers import BookSerializer


class BookViewSet(viewsets.ModelViewSet):
    queryset = Book.objects.all()
    serializer_class = BookSerializer

What does this code do?

ModelViewSet provides list, create, retrieve, update, partial update, and destroy actions automatically.

  • queryset tells the viewset which database records to operate on. Book.objects.all() means every book in the database.
  • serializer_class tells the viewset how to convert those records to and from JSON.
  • Save books/views.py.
  • You will not see a visible change yet. The next chunk wires this viewset to a URL so you can reach it in the browser.
Wire up the URLs with a router

A router inspects your viewset and automatically generates all the URL patterns you need for list, detail, create, update, and delete.

  • Create a new file called urls.py inside the books folder.
  • Add the following code to books/urls.py:
from rest_framework.routers import DefaultRouter

from .views import BookViewSet

router = DefaultRouter()
router.register(r"books", BookViewSet)

urlpatterns = router.urls

What does this code do?

DefaultRouter creates URL patterns for every action the viewset supports.

  • router.register(r"books", BookViewSet) registers the viewset at the books/ path prefix.
  • urlpatterns = router.urls exposes the generated patterns so Django can discover them.
  • Save books/urls.py.

The app-level URLs are ready. Now you need to connect them to the main project so Django knows to route requests starting with api/ to the books app.

  • Open bookshelf/urls.py in your editor.
  • Replace its entire contents with the following code:
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path("admin/", admin.site.urls),
    path("api/", include("books.urls")),
]

What does this code do?

include("books.urls") delegates any request starting with /api/ to the URL patterns defined in your books app.

Combined with the router in books/urls.py, this means your book list lives at /api/books/ and individual books live at /api/books/1/ (where 1 is the book's ID).

  • Save bookshelf/urls.py.
  • If your development server is not already running, start it by running:
python manage.py runserver
  • Open your browser and navigate to http://127.0.0.1:8000/api/books/.
  • You should see DRF's browsable API page with a list of the books you added through admin in the previous step.

Seeing an error page instead of the API?

  • Check that bookshelf/urls.py imports include from django.urls. A missing import causes an immediate error.
  • Confirm that books/urls.py exists and is saved. If Django cannot find the module, you will see a ModuleNotFoundError.
  • Make sure "rest_framework" is listed in INSTALLED_APPS in bookshelf/settings.py. Without it, DRF's templates will not load.

help me debug my Django REST Framework API endpoint

✔️ Awesome, I've got everything!

Great. Double check you have saved all four files before moving on.

ⓧ I'd like to double check the full code

Here is the full code for each file you created or modified in this step.

from rest_framework import serializers

from .models import Book


class BookSerializer(serializers.ModelSerializer):
    class Meta:
        model = Book
        fields = ["id", "title", "author", "published_year", "isbn", "description", "created_at"]
        read_only_fields = ["id", "created_at"]
from rest_framework import viewsets

from .models import Book
from .serializers import BookSerializer


class BookViewSet(viewsets.ModelViewSet):
    queryset = Book.objects.all()
    serializer_class = BookSerializer
from rest_framework.routers import DefaultRouter

from .views import BookViewSet

router = DefaultRouter()
router.register(r"books", BookViewSet)

urlpatterns = router.urls
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path("admin/", admin.site.urls),
    path("api/", include("books.urls")),
]

Your API is live and returning data. Next up, you will test all the CRUD operations to make sure creating, updating, and deleting books works end to end.

Test Your API

Your API is fully wired up with models, serializers, viewsets, and routers. Now it is time to confirm everything works by making real HTTP requests against your endpoints.

Django REST Framework includes a browsable API that renders an interactive HTML interface when you visit your endpoints in a browser. This lets you test CRUD operations without installing any extra tools.

In this step, get ready to:
  • Explore the browsable API in your browser.
  • Test all CRUD operations through the web forms.
  • Make API requests from the terminal with curl.
Explore the browsable API

The browsable API gives you a full HTML interface for interacting with your endpoints directly in the browser. No extra tools needed.

  • Make sure your development server is running. If it is not already running, start it by running this command:
python manage.py runserver
  • Open your browser and navigate to:
http://127.0.0.1:8000/api/

You should see a page titled Api Root with a link to the books endpoint.

  • Click the http://127.0.0.1:8000/api/books/ link.

You should see a JSON response listing the sample books you added through the admin panel earlier. The response includes pagination info and a results array containing your books.

  • Now visit a single book's detail page by adding an ID to the URL. Navigate to:
http://127.0.0.1:8000/api/books/1/

You should see the full JSON representation of a single book, along with a form at the bottom of the page for editing it.

What is the browsable API?

Django REST Framework detects when a request comes from a browser and automatically renders an HTML page instead of raw JSON. This page includes forms for submitting data, making it easy to test your API without writing any client code.

Test CRUD operations

CRUD stands for Create, Read, Update, and Delete. These are the four fundamental operations your API supports on book records.

Create a new book
  • Navigate back to http://127.0.0.1:8000/api/books/ in your browser.
  • Scroll down to the HTML form section at the bottom of the page.
  • Fill in the fields with this test data:
  • Title: The Great Gatsby
  • Author: F. Scott Fitzgerald
  • Published year: 1925
  • Isbn: 9780743273565
  • Description: A story of the mysteriously wealthy Jay Gatsby
  • Click the POST button.

You should see a response with HTTP status 201 Created and the full JSON representation of your new book, including the auto-generated id and created_at fields.

Update and delete a book
  • Click the link to the book you just created (check the id value in the response, then navigate to that detail URL like http://127.0.0.1:8000/api/books/3/).
  • In the HTML form at the bottom, change the description to A classic novel about the American Dream.
  • Click the PUT button.

You should see the updated book data in the response with your new description.

  • Now click the DELETE button (the red button at the top right of the page).
  • Confirm the deletion when prompted.

You should see a response with HTTP status 204 No Content, confirming the book has been removed.

  • Navigate back to http://127.0.0.1:8000/api/books/ and confirm the deleted book is no longer in the list.

What HTTP methods map to which CRUD operations?

GET retrieves data (Read). POST creates new records (Create). PUT replaces an entire record (Update). PATCH updates specific fields (Update). DELETE removes a record (Delete).

Your ModelViewSet handles all five of these methods automatically because it inherits from DRF's built-in mixins.

Test with curl

The browsable API is great for manual testing, but real API clients send requests programmatically. Let's confirm your endpoints work from the command line using curl.

  • Open a new terminal window or tab (keep the server running in your original terminal).
  • List all books by running this command:
curl http://127.0.0.1:8000/api/books/

You should see a JSON response containing your books in the results array.

  • Create a new book by running this command:
curl -X POST http://127.0.0.1:8000/api/books/ -H "Content-Type: application/json" -d '{"title": "Brave New World", "author": "Aldous Huxley", "published_year": 1932, "isbn": "9780060850524", "description": "A dystopian novel about a futuristic society"}'

You should see the newly created book returned as JSON with a 201 status.

  • Retrieve that single book using its ID (replace the number if yours is different):
curl http://127.0.0.1:8000/api/books/4/
  • Delete the book by running this command:
curl -X DELETE http://127.0.0.1:8000/api/books/4/

A successful delete returns no response body. This matches the 204 No Content status you saw in the browsable API.

Getting "Connection refused"?

Make sure your Django development server is still running in the other terminal window. If you stopped it, switch back to that terminal and run python manage.py runserver again.

Also confirm you are using http:// (not https://) in your curl commands.

help me debug a connection refused error when running curl against my Django development server

Why test with curl?

The browsable API uses your browser's session. curl sends raw HTTP requests without any browser context, which is how real API consumers (mobile apps, frontends, other services) interact with your API. If it works with curl, it works for any HTTP client.

Your REST API is fully tested and working. You have confirmed that all CRUD operations work through both the browser interface and the command line. Next up, take on the Secret Mission to add filtering and search to your API.

Secret mission

Add Filtering and Search

Your API returns every book in the collection every time. What if someone only wants books by a specific author, or wants to search across titles and descriptions? Add filtering and search to make your API production-ready.

Clean Up Your Resources

Clean Up Your Resources

Decide whether to keep your resources running, pause them to come back later, or delete them entirely.

This project runs entirely locally, so there are no ongoing costs. Your Django development server only uses resources while it is running.

Resources you used:

  • Django development server (local process).
  • Project folder on your Desktop (contains virtual environment, SQLite database, and all project files).

Keep everything running

No action needed. Choose this if you are still actively building or want to continue experimenting with your API.

  • Your project folder stays on your Desktop with all code, the virtual environment, and the SQLite database intact.
  • If you stopped the development server, restart it anytime by activating your virtual environment and running python manage.py runserver.

Pause - I'll come back to this later

Shut down the running development server to free up your terminal. Your files stay on disk so you can pick up where you left off.

  • Switch to the terminal where your Django server is running.
  • Press Ctrl+C to stop the server.
  • To resume later, open a terminal in your project folder, activate the virtual environment, and run python manage.py runserver.

Delete - I don't want to use this again

Remove all project files, the virtual environment, and the SQLite database. This cannot be undone.

  • If your development server is still running, press Ctrl+C in that terminal to stop it.
  • Delete your project folder from the Desktop by running these commands:

macOS

cd ~/Desktop
rm -rf [[PROJECT_FOLDER="your project folder name"]]

Windows

cd ~\Desktop
Remove-Item -Recurse -Force [[PROJECT_FOLDER="your project folder name"]]

This removes all Python packages (they lived inside the virtual environment), the SQLite database, and your project code in one step.

Nice Work!

Nice Work!

Congratulations! You just built a production-style REST API from scratch using Django and Django REST Framework.

You've learned how to:

  • Built a Django project with a custom app, a data model, and database migrations following Django's project conventions.
  • Configured Django admin for web-based data management and added sample data through the admin interface.
  • Created a full CRUD REST API using serializers, viewsets, and routers, then tested endpoints through the browsable interface and the command line.
  • Added filtering and search capabilities to your API so users can find books by author or search across titles and descriptions.

Ready to quiz yourself?