Python/Django: creating parent model that all models will inherit from
Question: I am attempting to create a model class that all models will inherit from when
they are created (in django). I want any model class, with any attributes to
be able to inherit from this class and read from the appropriate database
table. I know I am going need to use `**kwargs` and `.setattr()` at some point
but am unclear as to where I even start. I am also going to try to recreate
`.all()`, `.filter()` and `.get()` with in that class that all other methods
that inherit this class can access.

This is what I have so far...

    
    
    import sqlite3
    
    class Model:
    def __init__(self):
        pass
    
    @classmethod
    def all(self, **kwargs):
        pass
    
    @classmethod
    def get(self):
        pass
    
    @classmethod
    def filter(self):
        pass
    
    
    ###don't touch the code for these
    class Users(Model):
        pass
    
    class Stocks(Model):
        pass
    

Could somebody help me out with the initialization of ths class?


Answer: It looks like you're trying to insert an [abstract base
class](https://docs.djangoproject.com/en/1.9/topics/db/models/#abstract-base-
classes) for your models.

Basically, what you've got there is correct, except you're missing

    
    
    from django.db.models import Model
    class MyModelBase(Model):
         class Meta:
             abstract = True
    
         # ... The fields and methods I want all my models to inherit.
    

Then rather than making your models inherit from `django.db.models.Model`,
they should inherit from `MyModelBase`.

