From aae0441158451ab090663dd0a71a9d7c56a816b2 Mon Sep 17 00:00:00 2001 From: Matthias Kestenholz Date: Mon, 9 Dec 2024 13:04:39 +0100 Subject: [PATCH] Avoid silly migrations --- CHANGELOG.rst | 5 +++++ imagefield/fields.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2335ce1..3ba839b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,11 @@ Change log Next version ~~~~~~~~~~~~ +- Documented the ``preview`` spec used in the preview widget. +- Started masquerading our custom model fields as default Django image and char + fields. + + 0.20 (2024-11-18) ~~~~~~~~~~~~~~~~~ diff --git a/imagefield/fields.py b/imagefield/fields.py index 6cd1412..108b6d0 100644 --- a/imagefield/fields.py +++ b/imagefield/fields.py @@ -338,6 +338,10 @@ def field_label(self): def formats(self): return settings.IMAGEFIELD_FORMATS.get(self.field_label, self._formats) + def deconstruct(self): + name, _path, args, kwargs = super().deconstruct() + return (name, "django.db.models.ImageField", args, kwargs) + def contribute_to_class(self, cls, name, **kwargs): if self._auto_add_fields: if self.width_field is None: @@ -503,6 +507,10 @@ def __init__(self, *args, **kwargs): kwargs.setdefault("max_length", 20) super().__init__(*args, **kwargs) + def deconstruct(self): + name, _path, args, kwargs = super().deconstruct() + return (name, "django.db.models.CharField", args, kwargs) + def formfield(self, **kwargs): kwargs["widget"] = PPOIWidget return super().formfield(**kwargs)