#30214: Indexes defined on abstract base classes are not propagated to 
subclasses
-------------------------------------+-------------------------------------
               Reporter:  wKavey     |          Owner:  nobody
                   Type:             |         Status:  new
  Uncategorized                      |
              Component:  Database   |        Version:  2.1
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  abstract base class
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 It seems that if I define a model with Meta.abstract=True then any indexes
 I define in that model are not propgated to subclasses.

 Example:
 {{{
 class CustomBase(models.Model):
     id = models.AutoField(primary_key=True)
     name = models.CharField(max_length=100)

     class Meta:
         abstract = True
         indexes = [
             models.Index(fields=['name'], name='name_idx')
         ]

 class CustomSub(CustomBase):
     ip_address = models.GenericIPAddressField()

     class Meta:
         indexes = [
             models.Index(fields=['ip_address'], name='ip_address')
         ]
 }}}

 Then


 {{{
 >> python manage.py makemigrations
 - Create model CustomSub
 - Create index ip_address on field(s) ip_address of model customsub
 }}}

 No mention of index 'name_idx' from the base class

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30214>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.ccb9cb4e278403fc3b3756a4466605d0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to