Skip to content

Instantly share code, notes, and snippets.

@markddavidoff
Created December 1, 2023 20:16
Show Gist options
  • Save markddavidoff/132ba2f069626f5dbc850f7f53d67c38 to your computer and use it in GitHub Desktop.
Save markddavidoff/132ba2f069626f5dbc850f7f53d67c38 to your computer and use it in GitHub Desktop.
AbstractModelMeta a way to make django models abstract
class AbstractModelMeta(abc.ABCMeta, type(models.Model)):
"""
Set this as the metaclass to allow your abstract model to also be an ABC
ex:
```
class AbstractModelClass(models.Model, metaclass=AbstractModelMeta):
class Meta:
abstract = True
@abstractmethod
def implement_in_subclass(self):
pass
```
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment