0
我的一些django網址無法使用。我可以訪問我的索引頁面和django管理頁面。我可以登錄並創建對象沒有問題。例如,我可以創建一個網站,如下圖所示,但當我嘗試訪問網站集時,我會遇到404(甚至創建一個網站後)。我也使用Django allauth,並且這些頁面也對我的urlconf有麻煩。任何人都可以發現錯誤?Django Admin Url Not Working
例如,這個網址:
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/
我的URL配置如下:包含在第一URL配置
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)),
)
的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
。索引頁面工作得很好。
對於第二種情況,uri應該是'/ account/profile'而不是'/ accounts/profile'否 - ''s'',或者將urls.py改爲'^ accounts /'模式。 – Rohan
通過將管理員的網址帶到第一位來更改訂單 – drabo2005
您是否使用管理員的自定義模板?該錯誤與您的'redeem_reward'視圖有關,該視圖正在某處被調用。你應該發佈完整的回溯。 –