django-silk
django-silk copied to clipboard
User interface fails without session middleware
Hello, guys. I am trying to integrate silk with my existing app which does not use the atuhentication or sessions middleware. Because of that, I get the following error when I try to access /silk
:
...
File "/usr/local/lib/python3.6/site-packages/silk/views/summary.py", line 78, in get
c = self._create_context(request)
File "/usr/local/lib/python3.6/site-packages/silk/views/summary.py", line 57, in _create_context
raw_filters = request.session.get(self.filters_key, {})
AttributeError: 'WSGIRequest' object has no attribute 'session'
Is there a workaround? I considered just copying the views and tweaking until it worked, but looking at the code I wonder if the sessions are essential for the proper function of the interface. If so, maybe add a warning about that to the docs?
Hello!
-
As
SessionMiddleware
is used to persist the filters, could be a fix hide them on the UI if that is not present? -
Regarding the
AuthenticationMiddleware
I think is more complicated because is used inside of user_passes_test; any possible solution? Or documentate that is required is enough?
If the changes are OK I would like to implement them!
Thank you!
@SebCorbin sorry for the ping! But let me know if the ideas above makes sense for you, thank you!
@mgaligniana I suggest
- make the form agnostic from session if SessionMiddleware is not present (the test muse be
hasattr(request, 'session')
- as for AuthenticationMiddleware the
SILKY_AUTHENTICATION
should be enough to configure silk without auth but a simple accessrequest.user
inuser_passes_test
may raise anAttributeError
so we may need to change that - add some tests with these left out in
MIDDLEWARE
setting usingself.modify_settings
oroverride_settings
It has been half year but finally I added some progress! Sorry for the delay 🙏
I think I completed all your suggestions @SebCorbin! Let me know if they make sense for you and any change required.
Thank you!