Friday, September 23, 2016

Re: Model Meta is overwriten by abstract parent class

I see you posted the same thing in Trac: https://code.djangoproject.com/ticket/27264

For future reference, it's better not to duplicate posts. Otherwise, you might have multiple people duplicating effort to investigate the issue. Thanks.

On Friday, September 23, 2016 at 10:58:13 AM UTC-4, luxcem wrote:
Hi, it seems to be an actual django bug, the example at the address  https://docs.djangoproject.com/en/1.10/topics/db/models/#meta-inheritance  does not work correctly,        from django.db import models        class BaseCategory(models.Model):          title = models.CharField(max_length=100)            class Meta:              abstract = True              ordering = ['title']        class Category(BaseCategory):            name = models.CharField(max_length=100)            class Meta(BaseCategory.Meta):              ordering = ['name']              db_table = 'samble'    Category.Meta.ordering is equal to ['title'], Category.Meta.db_table is  undefined and Category.Meta.abstract is correctly set to false, in fact  Category.Meta is of type BaseCategory.Meta.    A stranger behavior is when `abstract = True` is added to the subclass :        class Category(BaseCategory):            name = models.CharField(max_length=100)            class Meta(BaseCategory.Meta):              abstract = True              ordering = ['name']              db_table = 'sample'    Now the behavior is correct (if abstract was not set) :  Category.Meta.db_table = 'sample', Category.Meta.ordering = ['name'] but  Category.Meta.abstract = False, Category.Meta is of type Category.Meta    So additionally it is impossible to create an abstract class inheriting  an abstract class.    Tested with django 1.8, 1.9, 1.10, 1.10.1 and python 2.7, 3.4  

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2eb9389b-90e6-4766-bdde-2072295796aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment