From c90c852052e580dd5025285717ea44614a2235af Mon Sep 17 00:00:00 2001 From: Bogdan Petrea Date: Mon, 12 Feb 2024 13:03:28 +0200 Subject: [PATCH] Change object_id to CharField because of MySQL's length requirement --- django_woah/migrations/0001_initial.py | 2 +- django_woah/models.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/django_woah/migrations/0001_initial.py b/django_woah/migrations/0001_initial.py index 4f97e68..572afeb 100644 --- a/django_woah/migrations/0001_initial.py +++ b/django_woah/migrations/0001_initial.py @@ -160,7 +160,7 @@ class Migration(migrations.Migration): ), ), ("perm", models.CharField(max_length=128)), - ("object_id", models.TextField(blank=True, null=True)), + ("object_id", models.CharField(blank=True, max_length=16, null=True)), ("non_model_resource_id", models.TextField(blank=True, null=True)), ( "content_type", diff --git a/django_woah/models.py b/django_woah/models.py index 24657c7..3534adb 100644 --- a/django_woah/models.py +++ b/django_woah/models.py @@ -253,8 +253,10 @@ class AssignedPerm(AutoCleanModel): ) perm = models.CharField(max_length=128) - content_type = models.ForeignKey(ContentType, models.CASCADE, null=True, blank=True) - object_id = models.TextField(null=True, blank=True) + content_type = models.ForeignKey( + ContentType, on_delete=models.CASCADE, null=True, blank=True + ) + object_id = models.CharField(null=True, blank=True, max_length=16) resource = GenericForeignKey("content_type", "object_id") non_model_resource_id = models.TextField(null=True, blank=True)