File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 3
3
from json import dumps as json_encode
4
4
5
5
import requests
6
+ from django .core .exceptions import ImproperlyConfigured
6
7
from django .http import HttpResponse
7
8
from django .template .loader import render_to_string
8
9
@@ -127,10 +128,19 @@ def build_merge_props(self):
127
128
def build_first_load (self , data ):
128
129
context , template = self .build_first_load_context_and_template (data )
129
130
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
+
130
140
return render_to_string (
131
141
template ,
132
142
{
133
- "inertia_layout" : settings . INERTIA_LAYOUT ,
143
+ "inertia_layout" : layout ,
134
144
** context ,
135
145
},
136
146
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
1
3
from pytest import warns
2
4
3
5
from inertia .test import InertiaTestCase , inertia_div , inertia_page
@@ -245,3 +247,13 @@ def test_merge_props_are_not_included_when_reset(self):
245
247
},
246
248
),
247
249
)
250
+
251
+
252
+ class MisconfiguredLayoutTestCase (InertiaTestCase ):
253
+ def test_with_props (self ):
254
+ with override_settings (INERTIA_LAYOUT = None ):
255
+ with self .assertRaisesMessage (
256
+ ImproperlyConfigured ,
257
+ "INERTIA_LAYOUT must be set" ,
258
+ ):
259
+ self .client .get ("/props/" )
You can’t perform that action at this time.
0 commit comments