Sorry in advance if this question look a bit superfluous but is something that is really bothering me.
I have a set of API's written in Django defined by the following urls.
# urls.py import ... urlpatterns = [ url(r"^api/v1/account", include(profile.urls)) ]
# profile/urls.py import ... urlpatterns = [ url(r"^$", AccountAPI.as_view()), url(r"^/login$", LoginAPI.as_view()), url(r"^/logout$", LogoutAPI.as_view()) ]
This configuration should allow only the urls:
/api/v1/account /api/v1/account/login /api/v1/account/logout
This work for my purpose but I keep having warnings like(I have several API defined with this rule and the warning list is way bigger):
?: (urls.W002) Your URL pattern '^/login$' has a regex beginning with a '/'. Remove this slash as it is unnecessary. ?: (urls.W002) Your URL pattern '^/logout$' has a regex beginning with a '/'. Remove this slash as it is unnecessary.
If I remove the slash the server will not validate the urls I defined. For that I have to had a slash to the first level of the urls like:
# urls.py import ... urlpatterns = [ url(r"^api/v1/account/", include(profile.urls)) ]
And this will make the account call to end with a slash, something I don't want to.
I feel that I have defined the urls the most elegant way I found to serve my purpose and I keep having this sad warnings in my logs.
Am I doing something wrong? Is there a right way to define the url's without compromising the structure I choose for them? Or there's a way of turning this warnings off?