Tuesday, November 25, 2014

Re: Meta inheritance across abstract base class

Hi,

If you define a new class Meta on C, then it will _replace_ the previous class Meta. You can, however have class Meta inherit other class Meta.
class Student(CommonInfo):
   
# ...
   
class Meta(CommonInfo.Meta):
        db_table
= 'student_info'

https://docs.djangoproject.com/en/dev/topics/db/models/#meta-inheritance

Collin


On Monday, November 24, 2014 8:19:50 AM UTC-5, Torsten Bronger wrote:
Hallöchen!

I have the following model structure:

    class A(models.Model):
        ...
        class Meta:
            ordering = ["timestamp"]
            get_latest_by = "timestamp"

    class B(A):
        class Meta(A.Meta):
            abstract = True

    class C(B):
        ...

Then, class C doesn't haven ordering or get_latest_by set.  Is this
expected behaviour?  Then, I would simply re-define them in B.

Tschö,
Torsten.

--
Torsten Bronger    Jabber ID: torsten...@jabber.rwth-aachen.de
                                  or http://bronger-jmp.appspot.com

--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ae594b2d-caba-4e4a-91ba-f840bf9f5781%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment