File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 33from json import dumps as json_encode
44
55import requests
6+ from django .core .exceptions import ImproperlyConfigured
67from django .http import HttpResponse
78from django .template .loader import render_to_string
89
@@ -127,10 +128,19 @@ def build_merge_props(self):
127128 def build_first_load (self , data ):
128129 context , template = self .build_first_load_context_and_template (data )
129130
131+ try :
132+ layout = settings .INERTIA_LAYOUT
133+ if not layout :
134+ raise AttributeError ("INERTIA_LAYOUT is set, but has a falsy value" )
135+ except AttributeError as ae :
136+ raise ImproperlyConfigured (
137+ "INERTIA_LAYOUT must be set in your Django settings"
138+ ) from ae
139+
130140 return render_to_string (
131141 template ,
132142 {
133- "inertia_layout" : settings . INERTIA_LAYOUT ,
143+ "inertia_layout" : layout ,
134144 ** context ,
135145 },
136146 self .request ,
Original file line number Diff line number Diff line change 1+ from django .core .exceptions import ImproperlyConfigured
2+ from django .test import override_settings
13from pytest import warns
24
35from inertia .test import InertiaTestCase , inertia_div , inertia_page
@@ -245,3 +247,12 @@ def test_merge_props_are_not_included_when_reset(self):
245247 },
246248 ),
247249 )
250+
251+
252+ class MisconfiguredLayoutTestCase (InertiaTestCase ):
253+ def test_with_props (self ):
254+ with override_settings (INERTIA_LAYOUT = None ), self .assertRaisesMessage (
255+ ImproperlyConfigured ,
256+ "INERTIA_LAYOUT must be set" ,
257+ ):
258+ self .client .get ("/props/" )
You can’t perform that action at this time.
0 commit comments