title: Django url warning urls.W002
body: <p>Sorry in advance if this question look a bit superfluous but is something that is really bothering me. </p>
  
  <p>I have a set of API's written in Django defined by the following urls.</p>
  
  <pre><code># urls.py
  import ...
  urlpatterns = [
      url(r"^api/v1/account", include(profile.urls))
  ]
  </code></pre>
  
  <p>and </p>
  
  <pre><code># profile/urls.py
  import ...
  urlpatterns = [
      url(r"^$", AccountAPI.as_view()),
      url(r"^/login$", LoginAPI.as_view()),
      url(r"^/logout$", LogoutAPI.as_view())
  ]
  </code></pre>
  
  <p>This configuration should allow <strong>only</strong> the urls:</p>
  
  <pre><code>/api/v1/account
  /api/v1/account/login
  /api/v1/account/logout
  </code></pre>
  
  <p>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):</p>
  
  <pre><code>?: (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.
  </code></pre>
  
  <p>If I remove the <strong>slash</strong> the server will not validate the urls I defined. For that I have to had a <strong>slash</strong> to the first level of the urls like:</p>
  
  <pre><code># urls.py
  import ...
  urlpatterns = [
      url(r"^api/v1/account/", include(profile.urls))
  ]
  </code></pre>
  
  <p>And this will make the account call to end with a slash, something I don't want to.</p>
  
  <p>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. </p>
  
  <p>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?</p>