[Django] 18 - DRF: Django Rest Framework
衔接:[Mobilar] 07 - REST API for Photo Mgt
Ref: Django REST Framework Views - ViewSets【非常不错,有结构图】
FQA
-
权限问题
Ref: giving "CSRF Failed: CSRF token missing or incorrect" while using both session and token login #164
REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', ) }
-
Base64如何保存imagefield
How to save Base64 encoded image to Django ImageField?
Ref: https://www.youtube.com/playlist?list=PLgCYzUzKIBE9Pi8wtx8g55fExDAPXBsbV
涉及到auth,不错的样子,系统教学;但这是2019年的,还是下面最新付费的好。
Section 11: API Documentation
Pay: Build a Backend REST API with Python & Django - Advanced
Create an advanced REST API with Python, Django REST Framework and Docker using Test Driven Development (TDD)
-
drf_spectacular 一种新的package
Ref: https://drf-spectacular.readthedocs.io/en/latest/
from drf_spectacular.views import ( SpectacularAPIView, SpectacularSwaggerView, ) urlpatterns = [ path('admin/', admin.site.urls), path('api/health-check/', core_views.health_check, name='health-check'), path('api/schema/', SpectacularAPIView.as_view(), name='api-schema'), path( 'api/docs/', SpectacularSwaggerView.as_view(url_name='api-schema'), name='api-docs', ), path('api/user/', include('user.urls')), path('api/recipe/', include('recipe.urls')), ]