django-sonar
django-sonar copied to clipboard
Feature request: exclude also i18n URLs
Hello.
It would be great if DJANGO_SONAR['excludes']
could automatically detect language code prefix in the URL path. So instead of setting this:
DJANGO_SONAR = {
'excludes': [
'/en/jsi18n/', '/sk/jsi18n/', '/cs/jsi18n/', '/pl/jsi18n/', '/hu/jsi18n/', '/uk/jsi18n/',
],
}
it would be able to use a using single path instead:
DJANGO_SONAR = {
'excludes': [
'/jsi18n/',
],
}
The jsi18n path is defined in urls.py using i18n patterns:
urlpatterns += i18n_patterns(
path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
)
Thanks!
Hello again.
Thanks for all these suggestions man.
I think the best way to solve these kind of issues is to support regex on the "excludes" parameter. In that way one could do something like this:
DJANGO_SONAR = {
'excludes': [
'/admin/', # Treated as literal string
'/__reload__/', # Treated as literal string
r'^/[a-z]{2}/jsi18n/', # Treated as regex pattern
],
}
I'll look into it for a future release.
Yes, that's exactly what I meant :) Thank you! Looking forward to it.