diff --git a/promgen/forms.py b/promgen/forms.py index 2479debd3..857213431 100644 --- a/promgen/forms.py +++ b/promgen/forms.py @@ -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 diff --git a/promgen/models.py b/promgen/models.py index 77014d772..03bd89cc0 100644 --- a/promgen/models.py +++ b/promgen/models.py @@ -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):