Commit | Line | Data |
---|---|---|
6837e829 PH |
1 | import glob |
2 | import sys | |
3 | import types | |
01b54c21 | 4 | |
6837e829 | 5 | from os.path import abspath, dirname, join |
01b54c21 | 6 | |
6837e829 | 7 | PROJECT_DIR = abspath(dirname(__file__)) |
01b54c21 | 8 | |
6837e829 PH |
9 | urlfiles = glob.glob(join(PROJECT_DIR, 'urls', '*.py')) |
10 | urlfiles.sort() | |
01b54c21 | 11 | |
6837e829 | 12 | urlpatterns = () |
01b54c21 | 13 | |
6837e829 PH |
14 | for f in urlfiles: |
15 | exec(open(abspath(f)).read()) | |
01b54c21 | 16 | |
6837e829 PH |
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 |