Skip to content

Instantly share code, notes, and snippets.

@gemcave
Last active September 23, 2020 05:34
Show Gist options
  • Save gemcave/7fd28a308b5d1d8e2356ce12d5c1f922 to your computer and use it in GitHub Desktop.
Save gemcave/7fd28a308b5d1d8e2356ce12d5c1f922 to your computer and use it in GitHub Desktop.
django redirect + filter
...
path('/filter/', views.FilterView.as_view(), name="type_filter"),
path('/filter/<page_slug>', views.FilterView.as_view(), name="type_filter_with_slug"),
def get_queryset(self):
if self.kwargs.get('page_slug'):
slug = self.kwargs.get('page_slug')
query_string = {
'green': 'street=2',
'russian': 'type=1',
}.get(slug)
base_url = reverse('type_filter')
url = '{}?{}'.format(base_url, query_string)
return redirect(url)
if (self.request.GET.getlist("type") or self.request.GET.getlist("street"):
// Поиск по базе данных используя полученные значения из query словаря
return queryset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment