#23657: Migrations framework doesn't properly handle factory-generated base
classes.
----------------------------+--------------------
     Reporter:  jfialkoff   |      Owner:  nobody
         Type:  Bug         |     Status:  new
    Component:  Migrations  |    Version:  1.7
     Severity:  Normal      |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0           |      UI/UX:  0
----------------------------+--------------------
 It is sometimes useful to construct models using factories. The code below
 shows one example of this. Other useful factories may or may not have
 fields (e.g., I have a base class factory that I use to add properties to
 an object with the urls for the object listing, edit page, create page and
 delete page).


 {{{
 def address_mixin_factory(address_required=True, city_required=True,
 state_required=True):
     # build base abstract model with the fields address, city and state
 and assign blank=True/False depending on the arguments.
     return AddressMixin

 class FullAddress(address_mixin_factory(), models.Model):
     pass

 class PartialAddress(address_mixin_factory(address_required=False),
 models.Model):
     pass
 }}}


 When you use Django migrations to migrate a model like this, the resulting
 migration file will have something like `bases=(AddressMixin,
 models.Model)`  in the call to `CreateModel` where, instead, we would want
 `bases=(address_mixin_factory(), models.Model)`. Also, while I have not
 tested this, I'm assuming the fields specified in the call to
 `CreateModel` will also be lacking the fields contributed by the factory-
 created base class.

--
Ticket URL: <https://code.djangoproject.com/ticket/23657>
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/052.03f9d6d4eae5125f97d1397f104c00a5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to