python - How to extend django abstract base model by inheritance? -


i'm trying extend django abstract base model via inheritance, django model's behavior automatically sets abstract = true abstract = false on subclasses of abstract models bothering me.

so situation is

from django.db.models import model django.db.models.base import modelbase  class timestampedmodel(model):     created_time = datetimefield()     modified_time = datetimefield()      class meta:         abstract = true         ordering = ('created_time',)         get_latest_by = 'created_time'   class recordmodelmetaclass(modelbase):     # not implemented yet     pass   class recordmodel(timestampedmodel):     __metaclass__ = recordmodelmetaclass      recording_model = notimplemented     recording_fields = notimplemented 

where abstract timestampedmodel base model abstract recordmodel.

the problem django's metaclass modelbase automatically converts recordmodel's abstract = true abstract = false when recordmodel defined in import time.

is there way turn off django's behavior?

yes, , documented:

if child wants extend parent’s meta class, can subclass it.

in case:

class recordmodel(timestampedmodel):     class meta(timestampedmodel.meta):         abstract = true 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -