{"id":20349379,"url":"https://github.com/liaogx/drf-tutorial","last_synced_at":"2025-08-20T20:32:35.252Z","repository":{"id":39757568,"uuid":"264408033","full_name":"liaogx/drf-tutorial","owner":"liaogx","description":"快速入门Django REST framework，学会开发一套自己的RESTful API服务，并且自动生成API文档。视频学习地址：","archived":false,"fork":false,"pushed_at":"2020-07-27T15:03:25.000Z","size":1585,"stargazers_count":185,"open_issues_count":0,"forks_count":75,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-07T20:50:05.408Z","etag":null,"topics":["django","django-rest-framework","python","restful-api","sqllite3"],"latest_commit_sha":null,"homepage":"https://www.imooc.com/learn/1274","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liaogx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-16T10:01:09.000Z","updated_at":"2025-04-07T06:24:53.000Z","dependencies_parsed_at":"2022-07-13T15:31:36.684Z","dependency_job_id":null,"html_url":"https://github.com/liaogx/drf-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/liaogx/drf-tutorial","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liaogx%2Fdrf-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liaogx%2Fdrf-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liaogx%2Fdrf-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liaogx%2Fdrf-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liaogx","download_url":"https://codeload.github.com/liaogx/drf-tutorial/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liaogx%2Fdrf-tutorial/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271378680,"owners_count":24749192,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-rest-framework","python","restful-api","sqllite3"],"created_at":"2024-11-14T22:25:43.156Z","updated_at":"2025-08-20T20:32:34.745Z","avatar_url":"https://github.com/liaogx.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Django REST framework快速入门\n\n\u003e 快速入门Django REST framework，学会开发一套自己的Restful API服务，并且自动生成API文档\n\n![drf-tutorial](./static/drf-tutorial.png)\n\n​\tAPI接口开发无需费时费力，本课程将从零开始引导同学们快速开发自己的Restful  API接口，从Django项目环境搭建、API接口生成数据、Postman接口测试到DRF认证方式的讲解，通过一个典型的课程信息接口（含增删改查），给同学们讲解完DRF中的序列化（serializers）、视图（viewsets）、路由（routers）、认证（authentication）、权限（permission），为将来前后端分离项目的开发打下基础。\n\n### 课程9个核心技术点\n\n1.  深入理解什么是Restful API\n2.  Django REST framework组件介绍\n3.  DRF中的序列化Serializers\n4.  Django的views开发API接口\n5.  DRF的多种视图api_view/APIView/GenericAPIView/viewsets\n6.  Django的URLs与DRF的Routers\n7.  如何使用DRF的API接口文档\n8.  API测试神器Postman\n9.  DRF的认证和权限\n\n### 适合人群\n\n\n​\t任何想学习Python前后端分离项目开发的同学。熟练Python语法，有Django项目基础。\n\n### 第一章 课程介绍\n\n#### 1.1 课程内容与导学\n\n​\t介绍本课程的学习内容和目标，如何学习本课程，引导学生对Django REST framework有一个基础的了解，并能够在课程结束后独立使用DRF完成简单的Restful API接口开发。\n\n### 第二章 Django REST framework介绍和项目准备\n\n#### 2.1 前后端分离介绍\n\n​\t前后端分离与不分离的区别，前后端分离项目的优劣。\n\n#### 2.2 深入理解什么是RESTful API\n\n​\tREST  API介绍，RESTful API接口设计的规范，有哪些最佳实践。\n\n#### 2.3 Pycharm搭建项目开发环境\n\n​\t搭建Django项目开发环境，如何在Pycharm中设置Django  server，点击“run”就直接运行项目。\n\n#### 2.4 Django REST framework介绍和安装\n\n​\tDjango  REST framework的组件介绍，让大家对DRF有一个初步的了解；安装DRF以及coreapi，Markdown等，介绍各自的功能场景。\n\n### 第三章 DRF中的序列化Serializers\n\n#### 3.1 开发课程信息模型类\n\n​\t创建课程应用，课程信息的模型类开发，讲解各字段和参数的含义，生成数据表。\n\n#### 3.2 什么是序列化\n\n​\t序列化介绍，序列化对象与反序列化对象的概念，如何重写.save()方法保存实例，如何使用验证器。\n\n#### 3.3 如何继承ModelSerializer序列化模型类\n\n​\t讲解如何序列化模型类中指定字段，关系字段的序列化深度，指定只读字段。\n\n#### 3.4 带URL的HyperlinkedModelSerializer\n\n​\t实现带URL字段的序列化结果，绝对和相对URL，如何更改URL字段名称。\n\n### 第四章 DRF的视图和路由\n\n#### 4.1 Django的views开发RESTful  API接口\n\n​\t讲解Django的views开发课程信息的CRUD接口，包括函数视图，类视图，通用类视图分别怎么写。\n\n#### 4.2 DRF中的装饰器api_view\n\n​\t如何使用api_view装饰函数，响应对应的HTTP方法，对比学习Django的FBV。\n\n#### 4.3 如何使用Postman测试API接口\n\n​\tPostman安装和介绍，演示如何使用Postman测试前面课程信息的Restfu  API接口。\n\n#### 4.4 DRF中的视图APIView\n\n​\t如何使用类视图APIView开发RESTful  API接口，Response的处理。\n\n#### 4.5 DRF中的通用类视图GenericAPIView\n\n​\t如何使用GenericAPIView开发RESTful  API接口，mixin与多种通用CRUD类视图的继承关系。\n\n#### 4.6 DRF的viewsets开发课程信息的增删改查接口\n\n​\t讲解DRF的viewsets开发课程信息的CRUD接口，与上一小节对比学习，演示DRF写RESTful  API接口的效率。\n\n#### 4.7 Django的URLs与DRF的Routers\n\n​\t讲解Django中urlpatterns的写法，路由课程信息接口，以及如何使用DRF的Routers更快更省事。\n\n### 第五章 DRF的认证和权限\n\n#### 5.1 DRF认证方式介绍\n\n​\t讲解常用的认证方式BasicAuthentication和SessionAuthentication，认证过程，请求头和响应头的变化。\n\n#### 5.2 Django信号机制自动生成Token\n\n​\tTokenAuthentication介绍和配置，如何使用Django信号机制为用户自动生成Token，提供获取Token的API接口。\n\n#### 5.3 DRF的权限控制\n\n​\t讲解权限检测后的处理，认证URL设置，全局权限控制与ViewSet的权限。\n\n### 第六章 如何使用DRF的API接口文档\n\n#### 6.1 如何生成API接口文档\n\n​\t设置DEFAULT_SCHEMA_CLASS和docs路由，访问文档页面。\n\n#### 6.2 DRF的概要使用方法介绍\n\n​\tDRF的概要功能讲解，如何配置认证，如何与接口数据交互。\n\n### 第七章 课程总结\n\n#### 7.1 课程总结\n\n​\t三种视图开发方式的比较，给未来的实战课来个预告。\n    \n![drf-tutorial](./static/DRF进阶与实战.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliaogx%2Fdrf-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliaogx%2Fdrf-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliaogx%2Fdrf-tutorial/lists"}