-
Notifications
You must be signed in to change notification settings - Fork 81
AAP-51350 Support Django 5.2 as well as Django 4.y #855
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
Open
AlanCoding
wants to merge
17
commits into
ansible:devel
Choose a base branch
from
AlanCoding:django5
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+193
−9
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e00af44
Try to run checks with Django 5.2
AlanCoding 0ca3a15
No need for this, question mark
AlanCoding b230345
Delete more
AlanCoding ab3e31e
Try to keep current working
AlanCoding 6e50ea3
dot-8 was too new
AlanCoding 1f9ad80
apply the fix I guess
AlanCoding 16c02c0
Make Django 5 the default
AlanCoding 6c14b88
Update the requirement the right way
AlanCoding e1eb71b
Make Django 4 the exception
AlanCoding bd66878
Prevent unintended downgrade and fix the environment matrix
AlanCoding d8710cb
Add migration to pick up help text change
AlanCoding d412f61
Correctly handle plural vs singular queryset
AlanCoding 42c4289
Falsy value handling
AlanCoding 6b1c0cf
Copy standard Django practice
AlanCoding 4262a90
Add a test for multi querysets
AlanCoding cfdfa62
Add test for hop in other direction
AlanCoding 59c8734
fix black issue
AlanCoding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
ansible_base/rbac/migrations/0009_objectrole_help_text_change.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Generated by Django 5.2.7 on 2025-10-06 13:50 | ||
# | ||
# This migration updates the help_text for the `users` and `teams` ManyToManyField | ||
# on the ObjectRole model to add trailing periods for consistency. | ||
# | ||
# WHY DJANGO 5 CREATES THIS BUT DJANGO 4 DOES NOT: | ||
# | ||
# Django 4's migration detector has a bug/limitation where it does not properly detect | ||
# help_text changes on ManyToManyField instances that use custom `through` tables. | ||
# The help_text was updated in the model code (ansible_base/rbac/models/role.py:518, 525) | ||
# to add trailing periods, but Django 4's makemigrations did not detect this change. | ||
# | ||
# Django 5 improved its field state serialization and comparison logic for ManyToManyFields, | ||
# particularly for fields with through tables, and now properly detects these help_text changes. | ||
# | ||
# This is a harmless migration that only updates field metadata (help_text) and does not | ||
# modify the database schema or affect data. | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dab_rbac', '0008_remote_permissions_cleanup'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
migrations.swappable_dependency(settings.ANSIBLE_BASE_TEAM_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='objectrole', | ||
name='teams', | ||
field=models.ManyToManyField(help_text='Teams or groups who have access to the permissions defined by this object role.', related_name='has_roles', through='dab_rbac.RoleTeamAssignment', through_fields=('object_role', 'team'), to=settings.ANSIBLE_BASE_TEAM_MODEL), | ||
), | ||
migrations.AlterField( | ||
model_name='objectrole', | ||
name='users', | ||
field=models.ManyToManyField(help_text='Users who have access to the permissions defined by this object role.', related_name='has_roles', through='dab_rbac.RoleUserAssignment', through_fields=('object_role', 'user'), to=settings.AUTH_USER_MODEL), | ||
), | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Prefetch Queryset Compatibility Issue
The
get_prefetch_queryset
compatibility method changed its check fromif not queryset
toif queryset is None
. This alters behavior when a falsy but non-None
value, like an empty list, is passed asqueryset
. Instead of generating a default queryset as before, the method now passes the falsy value directly, which can lead to an empty queryset being used where a default was expected, potentially breaking prefetch functionality.