Django redirecting everything to homepage
<p>I'm stuck with a Django project, I tried to add another app called login to make a login page but for some reason the page just redirects to the homepage except for the admin page</p>

<p>For example: 127.0.0.1:8000 will go to the homepage but 127.0.0.1:8000/login will also display the homepage even though I linked another template to it.</p>

<p>Here is my code: </p>

<p>main urls.py</p>

<pre><code>from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^', include('portal.urls')),
    url(r'^login/', include('login.urls')),
]
</code></pre>

<p>login urls.py</p>

<pre><code>from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^login/', views.index, name="login"),
]
</code></pre>

<p>login views.py</p>

<pre><code>from django.shortcuts import render

def index(request):
    return render(request, 'login/login.html')
</code></pre>

<p>portal urls.py</p>

<pre><code>from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^', views.index, name="portal"),
]
</code></pre>

<p>In addition, if the regex is login/$ but you enter http ://server/login, then it won't match wheras <a href="http://server/login/" rel="nofollow">http://server/login/</a> will.
You could try changing the regex to login/*$, which will match any number (even zero) / on the end of the url.</p>

<p>So http: //server/login, http: //server/login/, http: //server/login//// would all match.</p>

<p>Or if you want to be specific, login/{0,1}$ might work (though that regex syntax is from memory!)</p>

python django