views.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:django-danceschool 作者: django-danceschool 项目源码 文件源码
def dispatch(self, request, *args, **kwargs):
        ids = request.GET.get('ids')
        ct = getIntFromGet(request,'ct')

        try:
            contentType = ContentType.objects.get(id=ct)
            self.objectClass = contentType.model_class()
        except (ValueError, ObjectDoesNotExist):
            return HttpResponseBadRequest(_('Invalid content type passed.'))

        # This view only deals with subclasses of Events (Public Events, Series, etc.)
        if not isinstance(self.objectClass(),Event):
            return HttpResponseBadRequest(_('Invalid content type passed.'))

        try:
            self.queryset = self.objectClass.objects.filter(id__in=[int(x) for x in ids.split(',')])
        except ValueError:
            return HttpResponseBadRequest(_('Invalid ids passed'))

        return super(RepeatEventsView,self).dispatch(request,*args,**kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号