# 文章数据(单个表)
class ArticleDataViewSet(ModelViewSet):
authentication_classes = []
pagination_class = MyPag
filter_backends = (DjangoFilterBackend, OrderingFilter, )
filter_fields = ['article_data_en_id']
# filterset_class = ArticleDataFilter
ordering_fields = ['article_data_en_id', 'rele_time', 'update_time']
lookup_field = 'article_data_en_id'
def get_queryset(self):
if self.request.GET.get('language') == 'EN':
return ArticleDataEN.objects.all()
elif self.request.GET.get('language') == 'zh-CN':
return ArticleDataZHCN.objects.all()
def get_serializer_class(self):
if self.request.GET.get('language') == 'EN':
return ArticleDataENSerializer
elif self.request.GET.get('language') == 'zh-CN':
return ArticleDataZHCNSerializer
|