Created
December 1, 2023 20:16
-
-
Save markddavidoff/132ba2f069626f5dbc850f7f53d67c38 to your computer and use it in GitHub Desktop.
AbstractModelMeta a way to make django models abstract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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