diff --git a/src/pretix/helpers/countries.py b/src/pretix/helpers/countries.py index 4799d68249..2afdc5f94b 100644 --- a/src/pretix/helpers/countries.py +++ b/src/pretix/helpers/countries.py @@ -33,6 +33,15 @@ class CachedCountries(Countries): class FastCountryField(CountryField): def __init__(self, *args, **kwargs): kwargs.setdefault("countries", CachedCountries) + + if "max_length" not in kwargs: + # Override logic from CountryField to include 20% buffer. We don't want to migrate our database + # every time a new country is added to the system! + if kwargs.get("multiple", False): + kwargs["max_length"] = int(len(kwargs['countries']()) * 3 * 1.2) + else: + kwargs["max_length"] = 2 + super().__init__(*args, **kwargs) def check(self, **kwargs):