主网站网址:
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.conf import settings
from . import views
urlpatterns = [
url(r'^admin/', include (admin.site.urls)),
url(r'^vibeapp/', include('vibeapp.urls'))
]
Vibe app url Conf:
from django.conf.urls import patterns, url
from vibeapp import views
urlpatterns = patterns['vibeapp.views',
url(r'^$','index', name='index'),
url(r'^homepage/$, homepage, name='index'),
url(r'^vibeapp$', vibeapp, name='index'),
]
Vibeapp视图:
from django.http import HttpResponse
def index(request):
return HttpResponse("Hey!")
我包括我的wsgi,以防这可能是问题:
导入os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
application = get_wsgi_application()
我目前正在研究Django 1.9并配置了我的主网站网址和网络应用网址和视图。当我运行网址http://127.0.0.1:8000/vibeapp时,它会显示为未找到的网页。
请查看上面附带的代码。
由于
答案 0 :(得分:0)
您未正确使用 Vibe app url Conf 中的patterns
功能。您正在将它用作字典,它应该作为函数调用。请记住,patterns
已被弃用,它将在Django 1.10中消失。看看documention。
另一个问题是,你不应该重复同一组中的网址name=
,而不是重复“索引”中的网址:
...
url(r'^$','index', name='index'),
url(r'^homepage/$, homepage, name='index'),
url(r'^vibeapp$', vibeapp, name='index'),
...