title: if condition in urls.py - django
body: <p>I want to check <strong>if user not loged</strong>(don't have a session) he <strong>go to login.html</strong> file and <strong>if he loged</strong>(have a session) he go to <strong>profile.html</strong> , but i want to check it at urls.py</p>
  
  <p>My projects Tree :</p>
  
  <pre><code>manage.py
  url
  ----setting.py
  mr_url
  -----templates
  ---------url
  ------------profile.html
  ------------login
  -----------------logon.html
  -----views.py
  -----models.py
  -----urls.py
  </code></pre>
  
  <p>My <code>urls.py</code> :</p>
  
  <pre><code>from django.conf.urls import url
  from . import views
  from django.views.generic import TemplateView
  
  urlpatterns =[
      url(r'^$', views.profile, name='profile'),
  ]
  </code></pre>
  
  <p><strong>How i can check set session for user or not in <em>urls.py</em></strong>  ????</p>
  
  <p><strong>Note</strong> : i can do it in <code>views.py</code> but i don't want!</p>