Trying to use Django-filter
class based view FilterView
but I have problems with rendering filter in the template. It seems the filter is not in contex.
DOCS: https://django-filter.readthedocs.io/en/master/guide/usage.html#generic-view-configuration
EDIT: It seems that the get(self...)
function of the view is never being called. I've set breakpoints in get method and it didn't stopped there.
EDIT2: It's really weird. Debugger doesn't stop even on line: class UserFilterView(...)
filters.py
class UserProfileFilter(django_filters.FilterSet):
class Meta:
model = UserProfile
fields = ['budget','looking_for','user']
views.py
class UserFilterView(FilterView):
filterset_class = UserProfileFilter
template_name = 'frontend/userprofile_filter.html'
userprofile_filter.html
{% extends "frontend/base.html" %}
{% block content %}
<div class="filter">
{{ filter.form.as_p }}
</div>
<hr>
<div class="results">
</div>
{% endblock %}
But in browser, I see:
...
<div class="filter">
</div>
...
urls.py
url('^search/$',views.UserFilterView.as_view(), name="user_filter")
Can't figure out where is the problem. Do you have any ideas?