Closed benzkji closed 4 years ago
The models code requires the field types too; but yeah, the field types initialization could be even lazier.
OTOH adding choices to the model field makes sense too since it also ensures that the model has get_*_display
methods etc.
This approach works well in feincms3, and could serve as an inspiration for a solution to this problem: https://github.com/matthiask/feincms3/blob/cbcb9a94cfb701e69fce62a78bcf911fa0da7214/feincms3/mixins.py#L54
aaahh. get_*_display. the template mixin looks goods, as far as I can understand. I was a bit short thinking...just got in a migration mess on a sunday morning ,-) - documenting it (need of having form_designer in MIGRATION_MODULES) would also be a viable, less expensive option.
I was also about to make post about this. I tripped over same issue this week and took some time to figure out why migration was failing on CI system.
so, basically initializing with ("", "")
, and adding real values only after model initialization (class_prepared
signal), that would be it, right? I hope to stikc together a PR soonclass_prepared!
I don't think that's late enough; the migrations framework will probably still see the values when they are assigned in class_prepared
.
You probably have to move the assignment of field types into a modelform used in the admin panel.
ahhh. my initial thought, but not having a CharField only...see. will test. in feincms3 you do it then. curious.
Ah yes; changing the template configuration or apps etc. in feincms3 generates migrations actually, so the interesting part for this issue is only the ("", "")
thing.
Thank you; I found a less intrusive way of fixing this, which only affects the migration machinery.
Heads up: 0.17 is now available hopefully fixing this problem for good!
nice thx!
./manage.py makemigrations
with changed field types will trigger a new migration, that is created insite-packages/form_designer/migrations
- not what one wants. I propose to add a form to the inline, that then would define the choices, so they can be changed at any time. The db field would become a simpleCharField
.