8000 fix: Replaced `languages` field from `Page` which used to become inconsistent by fsbraun · Pull Request #8080 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

fix: Replaced languages field from Page which used to become inconsistent #8080

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

Merged
merged 8 commits into from
Nov 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove duplicates before asserting uniqueness constraint
  • Loading branch information
Github Release Action committed Nov 18, 2024
commit 491e8861449c9052908f69715db58ee6a1213bde
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Generated by Django 4.2.16 on 2024-11-14 06:48

from django.db import migrations
from django.db.models import Count


def remove_pageurl_duplicates(apps, schema_editor):
PageUrl = apps.get_model("cms", "PageUrl")
non_unique = PageUrl.objects.values("page_id", "language").annotate(total=Count("language")).filter(total__gt=1)
for item in non_unique:
for url in PageUrl.objects.filter(page_id=item["page_id"], language=item["language"])[1:]:
url.delete()


class Migration(migrations.Migration):
Expand All @@ -9,6 +18,7 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RunPython(remove_pageurl_duplicates),
migrations.RemoveField(
model_name="page",
name="languages",
Expand Down
0