Browse Source

[4.2.x] Refs #36098 -- Fixed validate_ipv4_address() crash for non-string values.

Regression in ca2be7724e1244a4cb723de40a070f873c6e94bf.
Sarah Boyce 2 months ago
parent
commit
57b0229421
1 changed files with 2 additions and 0 deletions
  1. 2 0
      django/core/validators.py

+ 2 - 0
django/core/validators.py

@@ -272,6 +272,8 @@ validate_unicode_slug = RegexValidator(
 
 
 def validate_ipv4_address(value):
+    if isinstance(value, ipaddress.IPv4Address):
+        return
     try:
         ipaddress.IPv4Address(value)
     except ValueError: