404在Django上添加新应用时错误



我在制作和合并第二个应用程序时对我的网站有问题。第一个效果很好。您可以在此处查看演示网站:http://216.158.236.51但是,当我尝试访问新的URL页面创建http://216.158.236.51/例如注册时,它只是给了我HTTP 404响应。它为我提供了新应用页面404,对于第一个应用程序中创建的其他新页面。

我很确定我从Django一侧正确地完成了所有操作。不知道我是否必须重新加载Nginx或Gunicorn,或者有哪些后端问题……任何建议都很棒。

我的URL模式看起来像这样:

from django.conf.urls import url, include
from django.contrib import admin
from blackcrowtours import views
from accounts import views
from django.conf.urls.static import static
from django.conf import settings
urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^accounts/', include('accounts.urls'), name='accounts'),
    url(r'^signup/', accounts.views.signup, name='signup'),
    url(r'^$', views.home, name='home'),
    url(r'^yourtrips/', views.yourtrips, name='yourtrips'),
    url(r'^about/', views.about, name='about'),
    url(r'^whyus/', views.whyus, name='whyus'),
    url(r'^accommodations/', views.accommodations, name='accommodations'),
    url(r'^yourguides/', views.yourguides, name='yourguides'),
    url(r'^westerneurotrip/', views.westerneurotrip, name='westerneurotrip'),
    url(r'^contact/', views.contact, name='contact'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

帐户应用程序视图

from django.shortcuts import render
from django.contrib.auth.models import User
from django.contrib.auth import authenticate, login
def signup(request):
return render(request, 'accounts/signup.html') 

帐户应用程序URL

from django.conf.urls import url
from . import views
app_name = 'accounts'
urlpatterns = [
    url(r'^signup/', views.signup, name='signup'),
    url(r'^login/', views.loginview, name='login'),
]   

blackcrowtours应用程序视图

from django.shortcuts import render

def home(request):
    return render (request, 'blackcrowtours/home.html',)
def yourtrips(request):
    return render (request, 'blackcrowtours/yourtrips.html',)
def about(request):
    return render (request, 'blackcrowtours/about.html',)
def whyus(request):
    return render (request, 'blackcrowtours/whyus.html',)
def accommodations(request):
    return render (request, 'blackcrowtours/accommodations.html',)
def yourguides(request):
    return render (request, 'blackcrowtours/yourguides.html',)
def westerneurotrip(request):
    return render (request, 'blackcrowtours/westerneurotrip.html',)
def contact(request):
    return render (request, 'blackcrowtours/contact.html',)

所有这些视图工作除了 contact URL外,我刚刚在事实之后添加了。

您的app.py文件看起来如何。您是否在installed_apps中添加了新/第二个应用?

相关内容

  • 没有找到相关文章

最新更新