This is one of the things I'd like to see on a code review checklist so 
this could be caught before a release. 

Any field that uses 'choices' needs to have its migrations modified to 
point to the variable name (e.g. choices=DJANGOCMS_STYLE_CHOICES) instead 
of the raw values. Otherwise, 'makemigrations' will copy the values into 
the migrations file, and when the choices get changed in code, the mismatch 
will trigger pointless migrations later. 

This issue can creep up repeatedly since if you later alter some other 
aspect of the field (e.g. help_text), it will again copy the raw choices 
values into the field definition in the migration, so it will need to be 
edited to point to the variable name instead.

This issue has come up many times with django-cms and related plugins, so 
it would be great to make this part of the code review checklist so end 
users aren't having to deal with this so often, if at all.

On Wednesday, November 16, 2016 at 11:20:12 AM UTC-8, Brian Rutledge wrote:
>
> I posted this issue to djangocms-style 
> <https://github.com/divio/djangocms-style/issues/32>, but it seems to me 
> that it affects multiple plugins, so I'm re-posting the description here.
>
> I just upgraded to 2.0.0, and discovered that setting 
> DJANGOCMS_STYLE_CHOICES and DJANGOCMS_STYLE_TEMPLATES results in changing 
> the choices for class_name 
> <https://github.com/divio/djangocms-style/blob/master/djangocms_style/models.py#L85-L90>
>  
> and template 
> <https://github.com/divio/djangocms-style/blob/master/djangocms_style/models.py#L67-L71>,
>  
> which necessitates new migrations. It looks any djangocms plugin that uses 
> this pattern (-link, -picture, etc.) will display this behavior. I am not 
> an expert on migrations, so it's not clear to me what problems it might 
> cause, but it make me nervous about future conflicts, and having migrations 
> outside of source control.
>

-- 
Message URL: 
https://groups.google.com/d/msg/django-cms-developers/topic-id/message-id
Unsubscribe: send a message to 
[email protected]
--- 
You received this message because you are subscribed to the Google Groups 
"django CMS developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/django-cms-developers/4ee6f3e1-8eac-46b1-82f2-2df93b693dde%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to