Closed SaadBazaz closed 3 years ago
Thank you! I'm in progress of improving tests and integrating basic CI/CD for this repo
There are some errors I keep running into though. I'll expand and share.
Can you please share you errors / problems in the discussions or submit known issues? Thank you very much for your contributions!
Hey @danyi1212, Sorry for the late response. Love your work on this, keep it up.
I tried integrating this in a project because I wanted access to django-messages cookie on my React frontend, but couldn't because of it being httpOnly = False. So I thought this would be a nice alternative (long polling a REST API for messages). However it doesn't work when I query from my React frontend (even the messages don't generate for some reason). But they are generated and work when I login to the Admin panel.
A broad reason I figured was because I am using FirebaseAuthentication + SessionAuthentication at the same time. e.g. if FirebaseAuth fails, then use SessionAuth. The React frontend utilizes FirebaseAuth.
What do you think? How can we investigate into this further?
Also a tiny request: Can we push this parenthesis issue into pip
? My docker container fails because of this :P
Hey, thank you for trying out this package!
Have you tried using MESSAGES_USE_SESSIONS = False
? I think by default the FirebaseAuthentication does not create a Django Session, then you may be unable to create / read the messages.
About the release, I'm improving the test coverage and fixing some other bugs. In the next few days I will publish that new release 😁
@SaadBazaz Just wanted to update you that the new release is published on PyPI.
@danyi1212 Received. Works on 3.7 but not 3.6.6 (which is ok)
Although, when enabling MESSAGES_USE_SESSIONS = False
, the Admin can't change things (I think because it can't find the Session for the message). What do you suggest?
Here is the error message:
Traceback (most recent call last):
File "/web/src/django/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/web/src/django/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/web/src/django/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/web/src/django/django/contrib/admin/options.py", line 607, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/web/src/django/django/utils/decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/web/src/django/django/views/decorators/cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/web/src/django/django/contrib/admin/sites.py", line 231, in inner
return view(request, *args, **kwargs)
File "/web/src/django/django/contrib/admin/options.py", line 1641, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "/web/src/django/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/web/src/django/django/utils/decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/web/src/django/django/contrib/admin/options.py", line 1522, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "/web/src/django/django/contrib/admin/options.py", line 1573, in _changeform_view
return self.response_change(request, new_object)
File "/usr/local/lib/python3.7/site-packages/parler/admin.py", line 361, in response_change
redirect = super().response_change(request, obj)
File "/web/src/django/django/contrib/admin/options.py", line 1307, in response_change
self.message_user(request, msg, messages.SUCCESS)
File "/web/src/django/django/contrib/admin/options.py", line 1068, in message_user
messages.add_message(request, level, message, extra_tags=extra_tags, fail_silently=fail_silently)
File "/web/src/django/django/contrib/messages/api.py", line 34, in add_message
return messages.add(level, message, extra_tags)
File "/usr/local/lib/python3.7/site-packages/drf_messages/storage.py", line 121, in add
Message.objects.create_message(self.request, message, level, extra_tags=extra_tags)
File "/usr/local/lib/python3.7/site-packages/drf_messages/models.py", line 89, in create_message
session = Session.objects.get(session_key=request.session.session_key)
File "/web/src/django/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/web/src/django/django/db/models/query.py", line 417, in get
self.model._meta.object_name
Exception Type: DoesNotExist at /en/admin/jpnintl/smartcard/48/change/
Exception Value: Session matching query does not exist.
Well, I guess you have found a bug! Can you please open an issue with that explanation?
And if you can please check and add details about your request.session
, like the type()
and dir()
?
Thank you!
Calling lru_cache without args is not possible in the latest Python because it acts as a function: https://stackoverflow.com/questions/47218313/use-functools-lru-cache-without-specifying-maxsize-parameter
This is untested so far, because I still can't get drf_messages to work properly. But at least it doesn't throw an error.