@@ -17,6 +17,7 @@ def reactpy_warnings(app_configs, **kwargs):
1717 from reactpy_django .config import REACTPY_FAILED_COMPONENTS
1818
1919 warnings = []
20+ INSTALLED_APPS : list [str ] = getattr (settings , "INSTALLED_APPS" , [])
2021
2122 # REACTPY_DATABASE is not an in-memory database.
2223 if (
@@ -53,10 +54,7 @@ def reactpy_warnings(app_configs, **kwargs):
5354 # Warn if REACTPY_BACKHAUL_THREAD is set to True with Daphne
5455 if (
5556 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 )
6058 ) and getattr (settings , "REACTPY_BACKHAUL_THREAD" , False ):
6159 warnings .append (
6260 Warning (
@@ -72,7 +70,7 @@ def reactpy_warnings(app_configs, **kwargs):
7270 warnings .append (
7371 Warning (
7472 "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 ." ,
7674 id = "reactpy_django.W004" ,
7775 )
7876 )
@@ -241,6 +239,22 @@ def reactpy_warnings(app_configs, **kwargs):
241239 )
242240 )
243241
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+
244258 return warnings
245259
246260
0 commit comments