Django 404:找不到页(404)URLConf不匹配

2024-05-16 23:31:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我是Django的新手,我的第一个主要项目是通过一个现有的Django Web应用程序来更新它,简化它,并尽可能地优化它。然而,我在让它在我的机器上运行时遇到了一些困难。你知道吗

导航到本地开发服务器时本地主机:8000/我得到以下错误:

Using the URLconf defined in core.urls, Django tried these URL patterns, in this order:

    ^home/$ [name='portal']
    ^agentexoplanet/admin/
    ^agentexoplanet/agentex/ [name='agentex_redirect']
    ^agentexoplanet/admin/agentex/event/(?P<planetid>\d+)/calibrators/(?P<calid>\d+)/$ [name='agentex_admin_calib']
    ^agentexoplanet/admin/agentex/event/(?P<planetid>\d+)/calibrators/$ [name='agentex_all_calib']
    ^agentexoplanet/admin/
    ^agentexoplanet/
    ^static/(?P<path>.*)$

The current URL, , didn't match any of these.

这就是核心.url文件:

from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.staticfiles import views
from django.views.generic import RedirectView
from django.contrib.auth.views import login, logout

from agentex import urls
from agentex.views import home
from agentex.admin import calibrator_check, allcalibrators_check
#from admin.site import urls

#from showmestars.views import newimage, latestimages

admin.autodiscover()

urlpatterns = [
    #(r'^api/', include('odin.api.urls')),
    url(r'^home/$', home, name='portal'),
    url(r'^agentexoplanet/admin/', include(admin.site.urls), name='agentexo_admin'),
    url(r'^agentexoplanet/agentex/', RedirectView.as_view(url='/agentexoplanet/'), name='agentex_redirect'),
    url(r'^agentexoplanet/admin/agentex/event/(?P<planetid>\d+)/calibrators/(?P<calid>\d+)/$',calibrator_check, name='agentex_admin_calib'),
    url(r'^agentexoplanet/admin/agentex/event/(?P<planetid>\d+)/calibrators/$',allcalibrators_check, name='agentex_all_calib'),
    url(r'^agentexoplanet/admin/', include(admin.site.urls), name=''), # QUERY
    url(r'^agentexoplanet/',include(admin.site.urls), name='agentexo_urls'),
    #url(r'^showmestars/newimage/$', newimage, {'eventid':0}, name='showmestars_newimage'),
    #url(r'^showmestars/(?P<eventid>\w+)/$', latestimages, name='showmestars_latestimage'),
    #url(r'^showmestars/$', latestimages, {'eventid':0}, name='showmestars_latestimage_event'),
    #url(r'^login/$',login, name='site_login'),
    #url(r'^logout/$',logout, name='site_logout'),
]

if settings.DEBUG:
    urlpatterns += [
        url(r'^static/(?P<path>.*)$', views.serve),
    ]

和我的项目(agentex)url文件:

from django.conf.urls import include, url
from django.contrib.auth.views import login, logout
from .views import *
from django.conf import settings

urlpatterns = [
    url(r'^$',index, name='index'),
    url(r'^account/login/$', login, {'template_name' :'login.html'}, name='login'),
    url(r'^account/logout/$', logout,{'template_name' :'logout.html'}, name='logout'),
    url(r'^account/register/$', register, name='register'),
    url(r'^account/$', editaccount, name='editaccount'),
    url(r'^profile/$',profile, name='profile'),
    url(r'^planets/$',target, name='target'),
    url(r'^fitsanalyse',fitsanalyse, name='fitsanalyse'),
    url(r'^test',tester, name='tester'),
    url(r'^briefing/read/$',read_manual_check, name='read_manual_check'),
    url(r'^briefing/$',briefing, name='briefing'),
    url(r'^comment/$',addcomment, name='addcomment'),
    url(r'^(?P<code>\w+)/view/$',addvalue, name='addvalue'),
    url(r'^(?P<code>\w+)/graph/update/$',updatedataset, name='updatedataset'),
    url(r'^(?P<code>\w+)/lightcurve/advanced/$',graphview, {'mode' : 'advanced','calid':None}, name='advanced-graph'),
    url(r'^(?P<code>\w+)/lightcurve/me/$',graphview, {'mode' : 'simple','calid':None}, name='my-graph'),
    url(r'^(?P<code>\w+)/lightcurve/calibrator/update/$',classifyupdate, name='classifyupdate'),
    url(r'^(?P<code>\w+)/lightcurve/calibrator/$',graphview, {'mode' : 'ave','calid':None}, name='average-graph'),
    url(r'^(?P<code>\w+)/lightcurve/calibrator/(?P<calid>\w+)/$',graphview, {'mode' : 'ave'}, name='calibrator-graph'),
    url(r'^(?P<code>\w+)/lightcurve/$',graphsuper,name='super-graph'),
    url(r'^(?P<code>\w+)/$',infoview, name='infoview'),
    url(r'^(?P<code>\w+)/data.(?P<format>\w+)',measurementsummary, name='measurementsummary'),
]

我不能完全肯定这里的错误。我的核心.url文件链接到索引.html,但我想它链接不正确。有人有什么想法吗?你知道吗

提前感谢(很抱歉没有发布图片-StackOverflow不允许我这样做)。你知道吗


Tags: djangonamefromimporturladminlogincode