1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # myapp/
# models/
# __init__.py
# models1.py
# models2.py
############# __init__.py #############
import django.db.models
import sys
appname = "myapp"
from models1 import *
from models2 import *
__all__ = []
for decl in globals().values():
try:
if decl.__module__.startswith(__name__) and issubclass(decl, django.db.models.Model):
decl._meta.db_table = decl._meta.db_table.replace('models', appname)
decl._meta.app_label = appname
__all__.append(decl.__name__)
django.db.models.loading.register_models(appname, decl)
except:
pass
|
More like this
- Breaking tests.py into multiple files by gsakkis 3 years, 1 month ago
- Dynamic Models Revisited by Ben 5 years, 7 months ago
- Test Django against many Pythons and databases by jacobian 6 years, 2 months ago
- Partial OpenID provider implementation from idproxy.net by simon 5 years, 10 months ago
- Auto-documenting Django Models with Sphinx by Voightkampff 1 year, 8 months ago
Comments