Skip to content
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

AttributeError: 'WSGIRequest' object has no attribute 'get_raw_uri' #1

Open
trankov opened this issue Feb 6, 2022 · 3 comments
Open

Comments

@trankov
Copy link

trankov commented Feb 6, 2022

After the installation and setup of this addon I've try to visit my /admin page and got an error:

Internal Server Error: /admin/
Traceback (most recent call last):
  File ".../lib/python3.10/site-packages/django/core/handlers/exception.py", line 47,
        in inner response = get_response(request)
  File ".../lib/python3.10/site-packages/django_loguru/middleware.py", line 25,
        in __call__ logger.info(f"URL: {request.get_raw_uri()}")
AttributeError: 'WSGIRequest' object has no attribute 'get_raw_uri'

UPDATED

As far as I investigate the issue, I found the news in Django 4.0 Deprecated Features:

The undocumented HttpRequest.get_raw_uri() method is removed. The HttpRequest.build_absolute_uri() method may be a suitable alternative.

Well, I fixed line 25 and changed get_raw_uri to build_absolute_uri. Then I saw a next Error Traceback:

Internal Server Error: /admin/
Traceback (most recent call last):
  File ...lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File ".../lib/python3.10/site-packages/django_loguru/middleware.py", line 29, in __call__
    logger.info(f"Data: {request.method.GET}")
AttributeError: 'str' object has no attribute 'GET'

Seems reasonable, because according to docs HttpRequest.method is a string type. Propably HttpRequest.GET was meant there. Which is returns QueryDict.

I corrected lines 28-41 to my liking, but I don't know what the author would like to put there. Therefore, I did not create a Pull Request, limiting myself to this comment.

@autoferrit
Copy link

I also get this when going to /api/docs and trying to execute one of the endpoints to list out records.

@tarsil
Copy link
Owner

tarsil commented Oct 12, 2022

@trankov firstly I owe you an apology. I literally never received a notification with this issue and this is the first time I hearing about. Truly, apologies.

@autoferrit im trying to replicate the issue but I'm my case I'm not receiving the same error.

Quick question to you both:

  1. Django version? Probably there were some breaking charges from the version 3.X to the version 4.

@trankov this is open source and therefore the community can contribute to a better approach. Feel free to open a PR if you see you can do it. I will try to replicate the issue in the meantime.

Thank you both.

Edit:

The purpose of the request.method was to understand and obtain the type of method from that specific request. Something has clearly changed in the recent versions that I'm not covering and this should definitely be updated.

@rgasper
Copy link

rgasper commented Sep 6, 2023

I also get this bug w/ django version 4.2.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants