Article Directory
1. Introduction to dependent packages
- coreapi (1.32.0+) - Schema generation support.
- Markdown (3.0.0+)-Markdown supports browsable API.
- Pygments (2.4.0+)-Add syntax highlighting to Markdown processing.
- django-filter (1.0.1+)-filtering support.
- django-guardian (1.1.1+)-Object level permission support
2. Install core packages and dependent packages
shell> pip3 install djangorestframework # 核心包
shell> pip3 install markdown django-filter coreapi Markdown Pygments django-guardian # 依赖包
3. Register to apply to the project
Adding rest_framework
to the project settings.py
in the INSTALLED_APPS
settings.
INSTALLED_APPS = [
...
'rest_framework',
]
4. Browser login verification
If you plan to use a browsable API, you may also need to add the login and logout views of the REST framework. Add the following to the root urls.py file
urlpatterns = [
...
path('api-auth/', include('rest_framework.urls')),
]