diff --git a/zgw_consumers/migrations/0022_set_default_service_slug.py b/zgw_consumers/migrations/0022_set_default_service_slug.py index aba6c9b..95fba02 100644 --- a/zgw_consumers/migrations/0022_set_default_service_slug.py +++ b/zgw_consumers/migrations/0022_set_default_service_slug.py @@ -16,6 +16,9 @@ def generate_unique_slug(original_slug, count=0): for row in Service.objects.all(): candidate_slug = slugify(row.label if row.label else row.api_root) + if len(candidate_slug) > 254: + candidate_slug = candidate_slug[:250] + row.slug = generate_unique_slug(candidate_slug) row.save(update_fields=["slug"]) @@ -34,6 +37,7 @@ class Migration(migrations.Migration): unique=False, blank=True, db_index=False, + max_length=255, ), preserve_default=False, ), diff --git a/zgw_consumers/models/services.py b/zgw_consumers/models/services.py index 641914a..1f2f130 100644 --- a/zgw_consumers/models/services.py +++ b/zgw_consumers/models/services.py @@ -44,6 +44,7 @@ class Service(RestAPIService): help_text=_( "A unique, human-friendly slug to identify this service. Primarily useful for cross-instance import/export." ), + max_length=255, ) api_type = models.CharField(_("type"), max_length=20, choices=APITypes.choices) api_root = models.CharField(_("api root url"), max_length=255, unique=True)