From the Django source, urlencode is basically a wrapper around Django's urlquote utility method. From the comments in the source, urlquote is a UTF-8-safe version of urllib.quote.

So urlencode is using the same defaults as python's urllib.quote, and the reason that urllib.quote does not escape slashes can be found in the documentation:

Replace special characters in string using the %xx escape. Letters, digits, and the characters '_.-' are never quoted. By default, this function is intended for quoting the path section of the URL. The optional safe parameter specifies additional characters that should not be quoted — its default value is '/'.

So, the reason is that it's escaping the path, and '/' is a perfectly expected and valid character within a path.

Answer from hrunting on Stack Overflow
🌐
Python
docs.python.org › 3 › library › urllib.parse.html
urllib.parse — Parse URLs into components — Python 3.14.6 ...
The resulting string is a series of key=value pairs separated by '&' characters, where both key and value are quoted using the quote_via function. By default, quote_plus() is used to quote the values, which means spaces are quoted as a '+' character and ‘/’ characters are encoded as /, which follows the standard for GET requests (application/x-www-form-urlencoded).
Discussions

python - Why does Django's `urlencode` not encode slash? - Stack Overflow
Isn't it accepted behavior to encode the slash, given that it's a reserved character in URLs? ... Let's see some use cases! ... Save this answer. ... Show activity on this post. From the Django source, urlencode is basically a wrapper around Django's urlquote utility method. From the comments in the source, urlquote is a UTF-8-safe version of urllib.quote. So urlencode is using the same defaults as python... More on stackoverflow.com
🌐 stackoverflow.com
Percent encoded forward slash is stil treated as a URL component delimiter
Expected Behavior When a forward slash (/) is percent encoded, it should not be treated as a delimiter in a URL but instead should be treated as a string character. from flask import Flask app = Fl... More on github.com
🌐 github.com
1
October 28, 2017
URL slash encoded
There was an error while loading. Please reload this page · FastAPI is not routing URL containing slash encoded More on github.com
🌐 github.com
16
December 14, 2019
How can I percent-encode URL parameters in Python? - Stack Overflow
A legacy compatibility wrapper to Python's urllib.parse.quote() function. (was used for unicode handling on Python 2) ... Save this answer. ... Show activity on this post. It is better to use urlencode here. There isn't much difference for a single parameter, but, IMHO, it makes the code clearer. More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › pallets › jinja › issues › 515
urlencode doesn't escape slashes · Issue #515 · pallets/jinja
November 20, 2015 - This was raised in #444, but this code always evaluates to b'/' on Python 3.4.1, so slashes still not escaped.
Author   pallets
🌐
URL Encoder
urlencoder.io › python
How to encode URLs in Python | URLEncoder
>>> import urllib.parse >>> params = {'name': 'Rajeev Singh', 'phone': ['+919999999999', '+628888888888']} >>> urllib.parse.urlencode(params, doseq=True) 'name=Rajeev+Singh&phone=+919999999999&phone=+628888888888' In Python 2.x the quote(), quote_plus(), and urlencode() functions can be accessed directly from the urllib package.
🌐
MojoAuth
mojoauth.com › binary-encoding-decoding › percent-encoding-url-encoding-with-python
Percent-encoding (URL Encoding) with Python | Binary Encoding Techniques Across Programming Languages
A common pitfall is failing to encode reserved characters such as /, ?, &, =, or # when they are intended as literal data, not as structural components of the URL. This can corrupt the URL's intended meaning. Always encode these characters if they are part of your data. Python's urllib.parse.quote() function handles this reliably.
🌐
ProxiesAPI
proxiesapi.com › articles › encoding-urls-in-python-with-urllib
Encoding URLs in Python with urllib | ProxiesAPI
For the full URL, we want to leave the forward slashes unencoded. When building URLs in code, it's best to encode each component as you construct the full URL. For example: ... from urllib.parse import urlencode base = "https://www.example.com" path = "/my path" query = {"foo": "bar"} path = quote(path) query = urlencode(query) full_url = base + path + "?" + query
🌐
Django
code.djangoproject.com › ticket › 22589
#22589 (url reverse should encode forward slashes) – Django
Here, page.title is a completely free-form string that might contain any characters, including forward slashes. I want to encode it completely. The current url reverse() code will quote any parameters using Django's urlquote, which will call Python's quote, which will encode all special characters, except the slash (and _.-).
Find elsewhere
🌐
PyTutorial
pytutorial.com › url-encoding-in-python-a-complete-guide
PyTutorial | URL Encoding in Python: A Complete Guide
January 28, 2026 - The slash remains. The space is encoded to . This is very useful for building complex URLs piece by piece. Query strings are a common part of URLs. They come after the question mark (?). Parameters are key-value pairs separated by ampersands (&). Encoding these manually with quote() is tedious and error-prone. The urllib.parse.urlencode() function is designed for this.
🌐
URL Encode
urlencoder.org › enc › python
URL Encoding of "python" - Online
Reserved characters are characters that sometimes have special meaning. For example, forward slash characters are used to separate different parts of a URL (or more generally, a URI).
🌐
DaniWeb
daniweb.com › programming › software-development › threads › 192290 › passing-variables-via-url-with-slashes
python - Passing variables via url with slashes | DaniWeb
May 15, 2009 - As Scru said, if you're trying to pass the values as a GET, you need to URLencode the string containing the date. If you feel some overwhelming need to do this manually, the URL encoding for a forward slash is '/'. Thus, it would look like this:
🌐
ProxiesAPI
proxiesapi.com › articles › handling-url-encoding-in-python-requests
Handling URL Encoding in Python Requests | ProxiesAPI
March 2, 2024 - quote_plus function from Python's ... The ampersand is the most common issue, but quote_plus can also handle encoding other special characters like spaces, slashes etc....
🌐
pytz
pythonhosted.org › percentcoding
percentcoding - fast url encoding and decoding
This is not surprising; the standard ... are pure Python. $ ./benchmark.py percentcodec.encode x 10000 0.348151922226 percentcodec.decode x 10000 0.381587028503 urllib.quote x 10000 4.51035284996 urllib.unquote x 10000 3.50923490524 ... All ASCII characters not occurring in the safe set are considered unsafe and will be escaped by encode. With quote and unquote, the '+' character does not map to a space, as is necessary for processing application/x-www-form-urlencoded...
🌐
GitHub
github.com › pallets › flask › issues › 2507
Percent encoded forward slash is stil treated as a URL component delimiter · Issue #2507 · pallets/flask
October 28, 2017 - Python version: Python 3.5.3 · ... /<string:company>/<string:user>. Company names and users would have to have the slash character disallowed otherwise they would not be able to be cleanly represented as a URL....
Author   pallets
🌐
Python
bugs.python.org › issue13866
Issue 13866: {urllib,urllib.parse}.urlencode should not use quote_plus - Python tracker
January 25, 2012 - This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/58074
🌐
SSOJet
ssojet.com › escaping › url-escaping-in-python
URL Escaping in Python | Escaping Techniques in Programming
Learn URL escaping in Python. Properly encode special characters for web requests and avoid errors. Master `urllib.parse` for reliable data transmission.
🌐
SEO North
seonorth.ca › seo north › server › how do you pass a slash in a url query string?
How do you pass a slash in a URL query string? - SEO North
March 25, 2026 - Here’s how you can encode slashes: let value = "example/data"; let encodedValue = encodeURIComponent(value); import urllib.parse · value = "example/data" encodedValue = urllib.parse.quote_plus(value) import java.net.URLEncoder; String value = "example/data"; String encodedValue = URLEncoder.encode(value, "UTF-8"); $value = "example/data"; $encodedValue = urlencode($value); These functions simplify encoding, ensuring special characters are correctly represented for seamless server communication.
🌐
GitHub
github.com › fastapi › fastapi › issues › 791
URL slash encoded · Issue #791 · fastapi/fastapi
December 14, 2019 - Describe the bug FastAPI is not routing URL containing slash encoded. To Reproduce Create a file with: from fastapi import FastAPI app = FastAPI() @app.get("/units/{unit}") def read_unit(unit: str): return {"unit": unit} Open the browser...
Author   fastapi
🌐
Read the Docs
python.readthedocs.io › en › latest › library › urllib.parse.html
21.8. urllib.parse — Parse URLs into components
November 15, 2017 - The resulting string is a series of key=value pairs separated by '&' characters, where both key and value are quoted using the quote_via function. By default, quote_plus() is used to quote the values, which means spaces are quoted as a '+' character and ‘/’ characters are encoded as /, which follows the standard for GET requests (application/x-www-form-urlencoded).