python - Django capturing wrong url pattern and going to another url -
keep in mind beginner django user, not have best idea of doing.
currently, have 2 urls - index , test. when go 127.0.0.1:8000/test, seems capture index pattern , go index page. 127.0.0.1:8000/ (index / home page) works fine.
project urls.py:
from django.conf.urls import include, url django.contrib import admin urlpatterns = [ url(r'^admin/$', include(admin.site.urls)), url(r'^test/$', include( 'twitterapp.urls' ) ), url(r'^$', include('twitterapp.urls') ), ]
app urls.py:
from django.conf.urls import url . import views urlpatterns = [ url(r'^$', views.index, name='index'), url(r'^test/$', views.test, name='test'), ]
views.py:
from django.shortcuts import render django.http import httpresponse django.template import requestcontext, loader # create views here. def index(request): context = {} return render(request, 'twitterapp/index.html', context) def test(request): return httpresponse("test page")
this basic issue, starting learn django, not sure why /test/ go index page. let me know if need clarification or see newbie errors in code. appreciated.
Comments
Post a Comment