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

[BUGFIX] Fix for foreign key check regarding m2m #497

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions promgen/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ def clean(self):
super().clean()
rule = models.Rule(**self.cleaned_data)

# In Django https://code.djangoproject.com/ticket/19580, some of the
# foreign key checks got stricter. We sets pk to 0 here so that it passes
# django's m2m/foreign key checks, but marks for us that it's a temporary
# rule that doesn't actually exist.
# We'll likely want to rework this assumption when we move to a different
# promql check
rule.pk = 0

# Make sure we pull in our labels and annotations for
# testing if needed
# See django docs on cached_property
Expand Down
4 changes: 2 additions & 2 deletions promgen/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,9 @@ class Meta:

def __str__(self):
return (
f"{self.name}"
f"{self.pk}:{self.name}"
if self.content_object is None
else f"{self.name} [{self.content_object.name}]"
else f"{self.pk}:{self.name} [{self.content_object.name}]"
)

def get_absolute_url(self):
Expand Down