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

Fix use of ip_address_validators for Django 5.1+ #9180

Merged
merged 2 commits into from
Jan 11, 2024

Conversation

kiendang
Copy link
Contributor

@kiendang kiendang commented Dec 4, 2023

Description

ip_address_validators return value changed in Django 5.1. Before Django 5.1, ip_address_validators returns a tuple containing 1) the list of validators and 2) the error message. Starting from Django 5.1 ip_address_validators only returns the list of validators. See django/django#17305. This make tests fail with ValueError: not enough values to unpack (expected 2, got 1).

This PR creates a compatibility shim for ip_address_validators for Django < 5.1 to behave the same way as in Django >= 5.1.

@auvipy auvipy self-requested a review December 5, 2023 19:33
@kiendang kiendang marked this pull request as draft December 8, 2023 04:06
@kiendang
Copy link
Contributor Author

kiendang commented Dec 8, 2023

Converting this to draft for now. That Django commit was not merged into 5.0 (my bad) but into main so will only cause issue in a later Django release. Will resurrect this when there's an actual Django release with the commit.

cclauss added a commit to cclauss/django-rest-framework that referenced this pull request Dec 10, 2023
cclauss added a commit to cclauss/django-rest-framework that referenced this pull request Dec 10, 2023
@kiendang kiendang marked this pull request as ready for review December 14, 2023 10:40
rest_framework/compat.py Outdated Show resolved Hide resolved
@kiendang kiendang marked this pull request as draft December 14, 2023 10:58
@kiendang kiendang changed the title Fix use of ip_address_validators for Django 5.0+ Fix use of ip_address_validators for Django 5.1+ Dec 14, 2023
@kiendang kiendang marked this pull request as ready for review December 14, 2023 11:08
@auvipy auvipy mentioned this pull request Jan 4, 2024
@auvipy auvipy added this to the 3.15 milestone Jan 11, 2024
@auvipy auvipy merged commit 21bb21b into encode:master Jan 11, 2024
8 checks passed
@kiendang kiendang deleted the ip_address_validators-compat branch January 11, 2024 13:18
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

Successfully merging this pull request may close these issues.

2 participants