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

Version: use field validator instead of custom field for slug #11957

Merged
merged 4 commits into from
Jan 28, 2025

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Jan 27, 2025

Instead of having a custom field with some extra complexity, we can achieve the same result by using a more standard django pattern, populating the field if isn't defined and using a validator. This will help to re-use this code in #11930.

@stsewd stsewd requested a review from a team as a code owner January 27, 2025 18:36
@stsewd stsewd requested a review from humitos January 27, 2025 18:36
Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good refactor! 👍🏼

@@ -77,7 +79,6 @@ class Migration(migrations.Migration):
field=readthedocs.builds.version_slug.VersionSlugField(
db_index=True,
max_length=255,
populate_from="verbose_name",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it OK to edit an old migration?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we don't depend on anything here, and it's already applied. We should squash these to remove the old field completely. #9510

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼 on squashing them

@stsewd stsewd merged commit 3b1b62e into main Jan 28, 2025
8 checks passed
@stsewd stsewd deleted the refactor-unique-slug branch January 28, 2025 15:08
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