详情页后台
路由:source/urls.py
1 2
|
router.register('free', views.CourseViewSet, 'free')
|
视图:source/views.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
from rest_framework.viewsets import GenericViewSet from rest_framework.mixins import ListModelMixin, RetrieveModelMixin from . import models, serializers
|
序列化:source/serializers.py
1 2 3 4 5 6 7 8 9 10 11 12 13
|
classCourseSectionSerializer(serializers.ModelSerializer): classMeta: model = models.CourseSection fields = ('name', 'orders', 'section_link', 'duration', 'free_trail')
classCourseChapterSerializer(serializers.ModelSerializer): coursesections = CourseSectionSerializer(many=True) classMeta: model = models.CourseChapter fields = ('name', 'chapter', 'summary', 'coursesections')
|
每天逼着自己写点东西,终有一天会为自己的变化感动的。这是一个潜移默化的过程,每天坚持编编故事,自己不知不觉就会拥有故事人物的特质的。 Explicit is better than implicit.(清楚优于含糊)