Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot import name 'urlquote' from 'django.utils.http'

I am trying to login to the admin portal, however I am getting the below error. Please help I have been searching for solution but nothing

Exception Type: ImportError at /admin/login/ Exception Value: cannot import name 'urlquote' from 'django.utils.http' (C:_project\my-events\env\lib\site-packages\django\utils\http.py)

like image 623
Masixole Kondile Avatar asked Sep 21 '25 12:09

Masixole Kondile


1 Answers

In Django 4, django.utils.http.urlquote(), urlquote_plus(), urlunquote(), and urlunquote_plus() are deprecated in favor of the functions that they’re aliases for: urllib.parse.quote(), quote_plus(), unquote(), and unquote_plus().

Downgrade to Django 3 to fix your issue. However, if you still want to use Django 4 and above, you can fix the issue by changing the reference of these functions. For your case, add the following to the top of settings.py:

from urllib.parse import quote

django.utils.http.urlquote = quote
like image 187
Solomon Botchway Avatar answered Sep 23 '25 03:09

Solomon Botchway