[Fixed]-Python Django: No Reverse Match at /startthread/

1👍

You don’t have a URL defined for the post_detail endpoint and the view_post view:

urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^register/$', views.register, name='register'),
    url(r'^login/$', views.login, name='login'),
    url(r'^logout/$', views.Logout, name='logout'),
    url(r'^startthread/$', views.add_post, name='startthread'),

    # ADDED
    url(r'^thread/(?P<slug>[-\w]+)/$', views.view_post, name='post_detail'),

    url(r'^tinymce/', include('tinymce.urls'))
]

And the reverse() would need to have a slug argument:

return redirect(reverse(post, kwargs={"slug": post.slug}))
👤alecxe

Leave a comment