Skip to content

Instantly share code, notes, and snippets.

@dryan
Created March 26, 2024 17:15
Show Gist options
  • Save dryan/20e5932306f590762d2395a8b35b20e6 to your computer and use it in GitHub Desktop.
Save dryan/20e5932306f590762d2395a8b35b20e6 to your computer and use it in GitHub Desktop.
Django false-positive migration
from django.contrib.gis.db import models
from django.utils.translation import gettext_lazy as _
def validate_is_true(value):
if value is not True:
raise ValidationError(validate_is_true.error_message)
validate_is_true.error_message = _("This field is required")
class Pledge(models.Model):
consent = models.BooleanField(
_("I agree to abide by the Prideraiser Terms of Service and Code of Conduct."),
default=False,
validators=[validate_is_true],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment