| 1 |
################################################################################ |
|---|
| 2 |
# Django M2M Kludge -- MUST BE LOADED FIRST! |
|---|
| 3 |
# |
|---|
| 4 |
# Courtesy of Benjamin Slavin on the django-users mailing list |
|---|
| 5 |
################################################################################ |
|---|
| 6 |
import os |
|---|
| 7 |
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' |
|---|
| 8 |
try: |
|---|
| 9 |
import settings # Assumed to be in the same directory. |
|---|
| 10 |
except ImportError: |
|---|
| 11 |
import sys |
|---|
| 12 |
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) |
|---|
| 13 |
sys.exit(1) |
|---|
| 14 |
from django.core.management import setup_environ |
|---|
| 15 |
from django.db.models.loading import get_models |
|---|
| 16 |
if __name__ == "__main__": |
|---|
| 17 |
setup_environ(settings) |
|---|
| 18 |
loaded_models = get_models() |
|---|
| 19 |
################################################################################ |
|---|