Created
December 21, 2018 08:03
-
-
Save JamCh01/252d7463ec048f254b44b19c60f8953e to your computer and use it in GitHub Desktop.
models.py
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
from django.db import models | |
from django.db.models.base import ModelBase | |
def models_generator(db_table): | |
class CustomMetaClass(ModelBase): | |
def __new__(cls, name, bases, attrs): | |
model = super(CustomMetaClass, cls).__new__( | |
cls, name, bases, attrs) | |
model._meta.db_table = db_table | |
print(db_table) | |
return model | |
class CustomModel(models.Model, metaclass=CustomMetaClass): | |
# Field | |
pass | |
return CustomModel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment