2
我想改變我的項目使用基於類的意見,我運行到一個奇怪的錯誤與我的網址的confDjango的:問題與網址的conf
我有一個歸類基於視圖:
class GroupOrTeamCreate(AjaxableResponseMixin, CreateView):
model = GroupOrTeam
fields = ['name', 'description']
#success_url = reverse('home_page') # redirect to self
我把最後一行註釋掉了,因爲如果我不這樣做,django會抱怨我的url conf中沒有模式。
要啓動,這是我的基地urls.py
urlpatterns = patterns('',
url(r'^$', TemplateView.as_view(template_name='core/home.html'), name='home_page'),
url(r'^administration/', include('administration.urls', app_name='administration')),
url(r'^reports/', include('reports.urls', app_name='reports')),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
)
顯然也有在那裏的模式。如果我註釋掉管理網址,它就會起作用。所以我認爲這個問題在某個地方。
管理urls.py
from django.conf.urls import patterns, url
from .views import ActiveTabTemplateView, GroupOrTeamCreate, GroupOrTeamUpdate
urlpatterns = patterns('',
# Add page
url(r'^add/$', ActiveTabTemplateView.as_view(template_name='administration/add.html'), name='add_page'),
url(r'^add/(?P<active_tab>\w+)/$', ActiveTabTemplateView.as_view(template_name='administration/add.html'),
name='add_page'),
# Seach page
url(r'^search/$', ActiveTabTemplateView.as_view(template_name='administration/search.html'), name='search_page'),
url(r'^search/(?P<active_tab>\w+)/$', ActiveTabTemplateView.as_view(template_name='administration/search.html'),
name='search_page'),
#--------------------------------------------------------------------------
# Forms
#--------------------------------------------------------------------------
# Groups and teams
url(r'^group-or-team-form/$', GroupOrTeamCreate.as_view(template_name='administration/forms/groups_form.html'),
name='group_or_team_form'),
url(r'^group-or-team-form/(?P<pk>\d+)/$',
GroupOrTeamUpdate.as_view(template_name='administration/forms/groups_form.html'),
name='group_or_team_form'),
)
我沒有看到這個問題。這些網頁加載只是罰款而沒有相反的聲明中,它似乎是引進,打破一切,但我相反的聲明不能爲我的生活找出原因是什麼。
很有道理!謝謝。 – ptr