File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ You will need to include ``devserver`` in your ``INSTALLED_APPS``::
34
34
'devserver',
35
35
)
36
36
37
+ If you're using ``django.contrib.staticfiles `` or any other apps with management
38
+ command ``runserver ``, make sure to put ``devserver `` *above * any of them (or *below *,
39
+ for ``Django<1.7 ``). Otherwise ``devserver `` will raise exception to ensure it is set up
40
+ properly.
41
+
37
42
-----
38
43
Usage
39
44
-----
Original file line number Diff line number Diff line change
1
+ import django
1
2
from django .core import exceptions
3
+ from django .core .exceptions import ImproperlyConfigured
2
4
3
5
from devserver .logger import GenericLogger
4
6
5
7
6
8
MODULES = []
7
9
8
10
11
+ def check_installed_apps_configuration ():
12
+ """
13
+ Check the app is put in correct order in INSTALLED_APPS
14
+
15
+ django.contrib.staticfiles runserver command is likely to
16
+ override devserver management command if put in wrong order.
17
+
18
+ Django had reversed order of management commands collection prior to 1.7
19
+ https://code.djangoproject.com/ticket/16599
20
+ """
21
+ from django .conf import settings
22
+ try :
23
+ staticfiles_index = settings .INSTALLED_APPS .index ('django.contrib.staticfiles' )
24
+ devserver_index = settings .INSTALLED_APPS .index ('devserver' )
25
+ except ValueError :
26
+ pass
27
+ else :
28
+ latest_app_overrides = django .VERSION < (1 , 7 )
29
+ if devserver_index < staticfiles_index and latest_app_overrides :
30
+ raise ImproperlyConfigured (
31
+ 'Put "devserver" below "django.contrib.staticfiles" in INSTALLED_APPS to make it work' )
32
+ elif devserver_index > staticfiles_index and not latest_app_overrides :
33
+ raise ImproperlyConfigured (
34
+ 'Put "devserver" above "django.contrib.staticfiles" in INSTALLED_APPS to make it work' )
35
+
36
+
9
37
def load_modules ():
10
38
global MODULES
11
39
@@ -37,4 +65,5 @@ def load_modules():
37
65
MODULES .append (instance )
38
66
39
67
if not MODULES :
68
+ check_installed_apps_configuration ()
40
69
load_modules ()
You can’t perform that action at this time.
0 commit comments