#23521: removal of concrete Model from bases doesn't remove it from ModelState
bases
-------------------------------------+-------------------------------------
     Reporter:  Sergey Fedoseev      |                    Owner:  Sergey
                                     |  Fedoseev
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  1.7
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by rm_):

 I had the need as described in #23818 but instead of squashing migrations
 i've created a migrations operator to update the bases on migrations
 models state. This works fine for me on django 1.8. I still haven't tested
 if django master behaves differently. Do you think this is a valuable
 addition to django?

 {{{
 class AlterBaseOperation(Operation):
     reduce_to_sql = False
     reversible = True

     def __init__(self, model_name, bases, prev_bases):
         self.model_name = model_name
         self.bases = bases
         self.prev_bases = prev_bases

     def state_forwards(self, app_label, state):
         state.models[app_label, self.model_name].bases = self.bases
         state.reload_model(app_label, self.model_name)

     def state_backwards(self, app_label, state):
         state.models[app_label, self.model_name].bases = self.prev_bases
         state.reload_model(app_label, self.model_name)

     def database_forwards(self, app_label, schema_editor, from_state,
 to_state):
         pass

     def database_backwards(self, app_label, schema_editor, from_state,
 to_state):
         pass

     def describe(self):
         return "Update %s bases to %s" % (self.model_name, self.bases)
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23521#comment:16>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.b63e98bfae35d2e06a8637a7e7264820%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to