Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detype_pattern function doesn't support class django.urls.resolvers.LocalePrefixPattern #1313

Open
fpoisson35 opened this issue Oct 15, 2024 · 2 comments

Comments

@fpoisson35
Copy link

Hello,

I'm trying to validate my spectacular configuration with the CLI like this :
python manage.py spectacular --color --validate --fail-on-warn --api-version v1

And i have this warning:
Warning: unexpected pattern "en/" encountered while simplifying urlpatterns.

When i search it seems that this is due to function detype_pattern which tests different class of pattern but not LocalePrefixPattern.

How could i change my configuration to resolve this warning ?

Thanks,
Regards,

@tfranzel
Copy link
Owner

Hi,

can you state an example to make this easier to reproduce? How are you using LocalePrefixPattern and how does the full path look like?

Seems like a bug, so we need to fix this and there is probably nothing you can do with the configuration alone (except for not using LocalePrefixPattern 😄 )

@fpoisson35
Copy link
Author

Hi,

We are using this import inside urls.py, which permit to insert our pattern with i18n_patterns:

from django.conf.urls.i18n import i18n_patterns

urlpatterns += i18n_patterns(
    path("accounts/", include("django.contrib.auth.urls")),
    path("admin/", admin.site.urls),
    path("", include("dashboard.urls")),
    ...

This is the function i18n_patterns which initialize LocalePrefixPattern, and the path presented with show_urls is like this :

/en/ dashboard.views.HomeView dashboard:home

Inside settings we have USE_I18N = True and LANGUAGES = (("en", _("English")), ("fr", _("French")))

Thanks in advance for your help !

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants