You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If someone wanted to use your defines template to generate a JavaScript version of your Python
129
-
class their settings file might look like this:
157
+
### URLGenerationFailed Exceptions & Placeholders
158
+
159
+
If you encounter a ``URLGenerationFailed`` exception you most likely need to register a placeholder for the argument in question. A placeholder is just a string orobject that can be coerced to a string that matches the regular expression for the argument:
130
160
131
161
```python
132
-
STATIC_TEMPLATES = {
133
-
'templates': [
134
-
'examples/defines.js'
135
-
]
136
-
}
162
+
from render_static.placeholders import register_variable_placeholder
Users should typically use a path instead of re_path and register their own custom converters when needed. Placeholders can be directly registered on the converter (and are then conveniently available to users of your app!):
173
+
174
+
```python
175
+
from django.urls.converters import register_converter
139
176
140
-
And then of course they would call `renderstatic` before `collectstatic`:
177
+
class YearConverter:
178
+
regex = '[0-9]{4}'
179
+
placeholder = 2000# this attribute is used by `url_to_js` to reverse paths
If you encounter a ``URLGenerationFailed`` exception you most likely need to register a placeholder for the argument in question. A placeholder is just a string orobject that can be coerced to a string that matches the regular expression for the argument:
318
+
If someone wanted to use your defines template to generate a JavaScript version of your Python
319
+
class their settings file might look like this:
323
320
324
321
```python
325
-
from render_static.placeholders import register_variable_placeholder
Users should typically use a path instead of re_path and register their own custom converters when needed. Placeholders can be directly registered on the converter (and are then conveniently available to users of your app!):
336
-
337
-
```python
338
-
from django.urls.converters import register_converter
339
329
340
-
class YearConverter:
341
-
regex = '[0-9]{4}'
342
-
placeholder = 2000# this attribute is used by `url_to_js` to reverse paths
330
+
And then of course they would call `renderstatic` before `collectstatic`:
0 commit comments