Django管理员网址不起作用

时间:2013-12-11 04:19:20

标签: python django admin urlconf

我的一些django网址无法使用。我可以访问我的索引页面和django管理页面。我可以登录并创建对象没问题。例如,我可以创建一个网站,如下所示,但是当我尝试访问网站集时,我会遇到404(即使在创建一个网站后)。我也在使用Django allauth,这些页面也遇到了我的urlconf问题。有人能发现错误吗?

例如,这个网址:

Page not found (404)
Request Method:     GET
Request URL:    http://myapp.com/admin/sites/site/

No reward found matching the query

这一个:

Page not found (404)
Request Method:     GET
Request URL:    http://shielded-island-1440.herokuapp.com/accounts/profile/

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

^ ^$ [name='index']
....
^ ^reward/$ [name='reward_list']
^ ^redeem/(?P<reward_code>)/$ [name='redeem_reward']
^ ^redeem/(?P<slug>\w+)/(?P<reward_code>\w+)/$ [name='reward_confirmation']
....
^account/
^sitemap\.xml$
^admin/

我的urlconf如下:

from django.conf.urls import patterns, include, url
from myapp.views import RewardSitemap

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
admin.autodiscover()

sitemaps = {'rewards':RewardSitemap}
urlpatterns = patterns('',
    url('^', include('myapp.urls', namespace="fluffy")),
    url(r'^account/', include('allauth.urls')),
    url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
    url(r'^admin/', include(admin.site.urls)),
)

第一个urlconf中包含的myapp网址:

urlpatterns = patterns('',
    url(r'^$', IndexView.as_view(), name="index"),
    ....
    url(r'^reward/$', RewardsList.as_view(), name="reward_list"),
    url(r'^redeem/(?P<reward_code>)/$', RedeemReward.as_view(), name="redeem_reward"),
    url(r'^redeem/(?P<slug>\w+)/(?P<reward_code>\w+)/$', RedeemConfirmation.as_view(), name="reward_confirmation"),
)

最后,我的ROOT_URLCONF设置为myapp.urls。索引页面工作正常。

1 个答案:

答案 0 :(得分:-1)

从我所拥有的有限知识中,我看到URl模式具有&#34; account /&#34;并且您正在访问&#34; http://shielded-island-1440.herokuapp.com/accounts/profile/&#34;它不会匹配URLConf中的任何正则表达式模式。

您可以尝试修改为网址(r&#39; ^ accounts /&#39;,include(&#39; allauth.urls&#39;)),?