From 99631d60302b06705720645dad9594012c368e4e Mon Sep 17 00:00:00 2001 From: Francesco Filicetti Date: Tue, 7 Nov 2023 10:22:54 +0100 Subject: [PATCH] fix: avoid creating new migrations on changing DynamicFields list --- django_form_builder/models.py | 8 +++++++- setup.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/django_form_builder/models.py b/django_form_builder/models.py index d12fb4f..5a87829 100644 --- a/django_form_builder/models.py +++ b/django_form_builder/models.py @@ -1,4 +1,5 @@ import json +import sys from django.db import models from django.utils.translation import gettext_lazy as _ @@ -8,12 +9,17 @@ from . utils import get_as_dict +_dynamic_fields = get_fields_types() +if 'makemigrations' in sys.argv or 'migrate' in sys.argv: # pragma: no cover + _dynamic_fields = [('', '-')] + + class DynamicFieldMap(models.Model): """ """ name = models.CharField(max_length=150,) field_type = models.CharField(max_length=100, - choices = get_fields_types()) + choices = _dynamic_fields) valore = models.TextField(max_length=20000, blank=True, default='', diff --git a/setup.py b/setup.py index fecfae5..9a7bf21 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( name='django-form-builder', - version='1.0.0', + version='1.0.1', packages=find_packages(), package_data={'': ['*.wav']}, data_files=[