Skip to content

Admin and API browser fails for views without a filter_class #3596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mcastle opened this issue Nov 4, 2015 · 4 comments
Closed

Admin and API browser fails for views without a filter_class #3596

mcastle opened this issue Nov 4, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@mcastle
Copy link
Contributor

mcastle commented Nov 4, 2015

The JSON browser does work though. It seems crispy forms breaks because it's expecting a filter form even when there is no filter_class set on a given view.

VariableDoesNotExist at /api/users/

Failed lookup for key [form] in u'None'

Template error:
In template /Users/user/virtualenvs/ddrsite/lib/python2.7/site-packages/rest_framework/templates/rest_framework/filters/django_filter_crispyforms.html, error at line 5
   (Could not get exception message)

   1 : {% load crispy_forms_tags %}
   2 : {% load i18n %}
   3 : 
   4 : <h2>{% trans "Field filters" %}</h2>
   5 :  {% crispy filter.form %}
@jpadilla jpadilla self-assigned this Nov 4, 2015
@jpadilla
Copy link
Member

jpadilla commented Nov 4, 2015

Ugh! Yeah that's definitely what I thought might happen with #3560. @mcastle can you confirm this is happening with the just released 3.3.1?

Update: Specifically talking about this comment on #3560.

@mcastle
Copy link
Contributor Author

mcastle commented Nov 4, 2015

Yep, this happened with 3.3.1.

@spout
Copy link

spout commented Nov 4, 2015

Same for me with 3.3.1, upgraded for #3560

@jpadilla jpadilla added the Bug label Nov 4, 2015
@jpadilla
Copy link
Member

jpadilla commented Nov 4, 2015

Thanks for confirming. So I think what should probably be happening here is that if there's no filter class the filter backend's to_html() returns None. It'd then be skipped here.

@tomchristie tomchristie added this to the 3.3.2 Release milestone Nov 9, 2015
mcastle added a commit to mcastle/django-rest-framework that referenced this issue Nov 16, 2015
Check if view has a filter_class. If not, skip trying to get and append a filter html element for it.
mcastle added a commit to mcastle/django-rest-framework that referenced this issue Dec 5, 2015
Uses encode#3597, but without using `Context`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants