views.py 文件源码

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

项目:perdiem-django 作者: RevolutionTech 项目源码 文件源码
def dispatch(self, request, *args, **kwargs):
        # Filtering
        self.active_genre = request.GET.get('genre', 'All Genres')
        self.distance = request.GET.get('distance')
        self.location = request.GET.get('location')
        self.lat = request.GET.get('lat')
        self.lon = request.GET.get('lon')

        # Sorting
        order_by_slug = request.GET.get('sort')
        if order_by_slug not in self.ORDER_BY_NAME:
            order_by_slug = 'recent'
        self.order_by = {
            'slug': order_by_slug,
            'name': self.ORDER_BY_NAME[order_by_slug],
        }

        # Geolocate if location
        self.location_coordinates = None
        self.geocoder_failed = False
        if self.location:
            geolocator = Nominatim()
            try:
                self.location_coordinates = geolocator.geocode(self.location)
            except GeocoderTimedOut:
                self.geocoder_failed = True

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


问题


面经


文章

微信
公众号

扫码关注公众号