To add Django REST Framework (DRF) to an existing Django project, install the djangorestframework package in the project’s Python environment, add rest_framework to the active settings module’s INSTALLED_APPS, then create API views and connect their URLs to the project’s existing URL configuration. You do not need to create a new Django project.
Check Django and Python compatibility first
DRF’s current requirements page lists Django 5.2, 6.0, and 6.1, and Python 3.10 through 3.15. It recommends and officially supports the latest patch release in each listed series. DRF’s release notes identify version 3.18.0, dated 7 August 2026, and note support for Django 6.1. These version details can change; check the official requirements and release notes against the versions pinned in your project before installing or upgrading.
As an Amazon Associate I earn from qualifying purchases.
Install DRF in the existing project environment
-
Activate the virtual environment used by your Django project, or otherwise ensure the Python executable you use targets that environment.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
From your project directory, install DRF with
python -m pip install djangorestframework. The package name on PyPI isdjangorestframework; the Django app label used in settings is different.#1 Best Overall
-
Open the settings module actually used when running the project. Add
rest_frameworkto itsINSTALLED_APPSlist:INSTALLED_APPS = [ # Existing Django and project apps... "rest_framework", ]
These are the required installation and app-registration steps in DRF’s installation instructions. You do not need to clone DRF’s repository for a normal application install; source checkout is an alternative mainly for source or development work.
Add API views and routes to your existing apps
Put serializers and API views in the Django app that owns the relevant data or functionality. Then expose those views through the project’s existing URL configuration. DRF offers two common approaches: a router for viewsets when its standard routes fit, or explicit URL patterns when you want more direct control.
Recommended Free Tools
Rank #2
Use a router with a viewset
For a viewset, create a router, register the viewset, and include the router’s URLs from the root URL configuration. The following illustrates the wiring; replace the example import and viewset with those in your app.
# project/urls.py
from django.urls import include, path
from rest_framework.routers import DefaultRouter
from myapp.views import ItemViewSet
router = DefaultRouter()
router.register("items", ItemViewSet)
urlpatterns = [
path("api/", include(router.urls)),
]
DRF’s quickstart demonstrates this pattern. A router generates the standard URL patterns for registered viewsets, reducing routine routing boilerplate.
Write explicit URL patterns for more control
If the API needs specific paths or you prefer to define each route yourself, use regular class-based views and add their paths directly to the existing URL configuration. DRF supports this approach as well; the quickstart notes that explicit URL configuration is available when more control is needed.
| Approach | Best fit | Trade-off |
|---|---|---|
| Router with viewsets | Standard routes for viewsets | Less routing boilerplate; route shape follows the router and viewset conventions. |
| Explicit URL patterns | Routes that need direct, individual URL control | More routing declarations to maintain, with direct control over each path. |
Choose optional URLs and packages only when needed
Browsable API login and logout
You may include rest_framework.urls to provide login and logout views useful with the browsable API. For example, add a path such as api-auth/ to the existing URL configuration. The prefix is up to the project, and these URLs are not required for every API.
Feature-specific packages
DRF’s installation documentation associates these optional packages with specific capabilities. Install only the ones your application intends to use.
| Optional package | Documented use |
|---|---|
| PyYAML and uritemplate | Schema generation |
| Markdown | Markdown support in the browsable API |
| django-filter | Filtering |
| django-guardian | Object-level permissions |
See the DRF installation page for the package details. These dependencies are not prerequisites for registering DRF or adding basic API routes.
Configure global DRF settings when your API needs them
DRF can read global options from a REST_FRAMEWORK dictionary in Django settings. Add it when you need to set shared behavior—for example, the quickstart shows pagination configuration. Choose authentication, permissions, serializers, and views to match your application; adding DRF alone does not determine those API policies.
Verify the integration
-
Confirm the install command ran in the same Python environment used by the project.
DriversCrashes, No Sound, or Screen Glitches?PerformancePC Slower Than It Used to Be?DriversOutdated Drivers Are Slowing You DownSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Confirm
rest_frameworkis in theINSTALLED_APPSlist for the settings module actually loaded by the project.Best Value
-
Confirm the root URL configuration includes the explicit API paths or the router’s
router.urls. -
If you added optional dependencies or a
REST_FRAMEWORKsetting, confirm each is needed and configured for the feature you intend to use.
Further learning
For a broader guide beyond installation and wiring, Will Vincent’s Django for APIs, Fifth Edition covers Django REST Framework; check that edition’s fit for the Django versions used by your project. The author also lists an associated Django for APIs course on the same page.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




