restframework框架写api中的个人理解以及碰到的问题
2021-04-20 20:27
标签:ace 集成 ued 替换 load sel 富文本编辑器 ret ide 关于DjangoUeditor上一篇文章中也有介绍,有需要的可以去看一哈。。。 restframework框架写api中的个人理解以及碰到的问题 标签:ace 集成 ued 替换 load sel 富文本编辑器 ret ide 原文地址:https://www.cnblogs.com/zzy0306/p/8608396.htmlclass GuideWordViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
"""文章索引"""
queryset = GuideWord.objects.all()
serializer_class = GuideWordSerializer
company = models.ForeignKey(Company, related_name=‘company_video‘, verbose_name=‘公司‘, blank=True, null=True) (model中的外键字段)
class GuideVideoSerializer(serializers.ModelSerializer):
class Meta:
model = GuideVideo
fields = (‘id‘, ‘title‘, ‘video‘, ‘country‘,)
class ReCompanySerializer(serializers.ModelSerializer):
company_video = GuideVideoSerializer(many=True, read_only=True)
class Meta:
model = Company
fields = (‘id‘, ‘name‘, ‘country‘, ‘image‘, ‘company_video‘,)
def save(self, *args, **kwargs):
self.content = self.content.replace(‘"‘, "‘")
return super(GuideWord, self).save(*args, **kwargs)
upload_settings={‘imageMaxSize‘: 1204000,
‘videoPathFormat‘: "guide/videos/%(basename)s_%(datetime)s.%(extname)s"}
文章标题:restframework框架写api中的个人理解以及碰到的问题
文章链接:http://soscw.com/index.php/essay/77288.html