@@ -17,6 +17,7 @@ def reactpy_warnings(app_configs, **kwargs):
17
17
from reactpy_django .config import REACTPY_FAILED_COMPONENTS
18
18
19
19
warnings = []
20
+ INSTALLED_APPS : list [str ] = getattr (settings , "INSTALLED_APPS" , [])
20
21
21
22
# REACTPY_DATABASE is not an in-memory database.
22
23
if (
@@ -53,10 +54,7 @@ def reactpy_warnings(app_configs, **kwargs):
53
54
# Warn if REACTPY_BACKHAUL_THREAD is set to True with Daphne
54
55
if (
55
56
sys .argv [0 ].endswith ("daphne" )
56
- or (
57
- "runserver" in sys .argv
58
- and "daphne" in getattr (settings , "INSTALLED_APPS" , [])
59
- )
57
+ or ("runserver" in sys .argv and "daphne" in INSTALLED_APPS )
60
58
) and getattr (settings , "REACTPY_BACKHAUL_THREAD" , False ):
61
59
warnings .append (
62
60
Warning (
@@ -72,7 +70,7 @@ def reactpy_warnings(app_configs, **kwargs):
72
70
warnings .append (
73
71
Warning (
74
72
"ReactPy client.js could not be found within Django static files!" ,
75
- hint = "Check your Django static file configuration ." ,
73
+ hint = "Check all static files related Django settings and INSTALLED_APPS ." ,
76
74
id = "reactpy_django.W004" ,
77
75
)
78
76
)
@@ -241,6 +239,22 @@ def reactpy_warnings(app_configs, **kwargs):
241
239
)
242
240
)
243
241
242
+ position_to_beat = 0
243
+ for app in INSTALLED_APPS :
244
+ if app .startswith ("django.contrib." ):
245
+ position_to_beat = INSTALLED_APPS .index (app )
246
+ if (
247
+ "reactpy_django" in INSTALLED_APPS
248
+ and INSTALLED_APPS .index ("reactpy_django" ) < position_to_beat
249
+ ):
250
+ warnings .append (
251
+ Warning (
252
+ "The position of 'reactpy_django' in INSTALLED_APPS is suspicious." ,
253
+ hint = "Move 'reactpy_django' below all 'django.contrib.*' apps, or suppress this warning." ,
254
+ id = "reactpy_django.W018" ,
255
+ )
256
+ )
257
+
244
258
return warnings
245
259
246
260
0 commit comments