As per the documentation for JavaScriptCatalog
, I added the following lines to the urlpatterns
in one of my Django apps:
from django.views.i18n import JavaScriptCatalog
from django.conf.urls import url
urlpatterns = [
# ...
url(r"^jsi18n/?", JavaScriptCatalog.as_view(), name="javascript-catalog"),
# ...
]
But if I navigate to http://localhost/jsi18n, I see that it's not loading the catalog:
// ...
/* gettext library */
django.catalog = django.catalog || {};
if (!django.jsi18n_initialized) {
// ...
How do I go about debugging this? How can I insert a breakpoint()
into the JavaScriptCatalog.as_view()
value to see what it's doing and where it's looking?
Subclass the original class, put a breakpoint()
in its __init__
and then call super().__init__
:
from django.views.i18n import JavaScriptCatalog
from django.conf.urls import url
class MyCatalog(JavaScriptCatalog):
def __init__(self, *args, **kwargs):
breakpoint()
return super().__init__(*args, **kwargs)
urlpatterns = [
# ...
url(r"^jsi18n/?", MyCatalog.as_view(), name="javascript-catalog"),
# ...
]
Or overwrite some other method, such as get_catalog
:
class MyCatalog(JavaScriptCatalog):
def get_catalog(self, *args, **kwargs):
breakpoint()
return super().get_catalog(*args, **kwargs)