| 1 | import glob |
| 2 | import sys |
| 3 | import types |
| 4 | |
| 5 | from os.path import abspath, dirname, join |
| 6 | |
| 7 | PROJECT_DIR = abspath(dirname(__file__)) |
| 8 | |
| 9 | urlfiles = glob.glob(join(PROJECT_DIR, 'urls', '*.py')) |
| 10 | urlfiles.sort() |
| 11 | |
| 12 | urlpatterns = () |
| 13 | |
| 14 | for f in urlfiles: |
| 15 | exec(open(abspath(f)).read()) |
| 16 | |
| 17 | # from https://github.com/2general/django-split-settings/blob/master/split_settings/tools.py |
| 18 | # add dummy modules to sys.modules to make runserver autoreload work with |
| 19 | # settings components |
| 20 | modulename = '_urls.%s' % f |
| 21 | module = types.ModuleType(modulename) |
| 22 | module.__file__ = f |
| 23 | sys.modules[modulename] = module |