1👍
✅
You didn’t pass name
as keyword argument to in your url function in order to use named urls.
Something like this should work fine:
url(r'^blogs/(?P<pk>[0-9]+)/$', views.BlogDetail.as_view(), name='details')
1👍
Finally, I resolved this. I have simply added a name to my url and used the same name in template as below
added name attribute in urls.py
from django.conf.urls import url, include
from blogg import views
from rest_framework.urlpatterns import format_suffix_patterns
urlpatterns = [
url(r'^blogs/$', views.BlogList.as_view()),
url(r'^blogs/(?P<pk>[0-9]+)/$', views.BlogDetail.as_view(), name = 'blog_details'),
]
urlpatterns = format_suffix_patterns(urlpatterns)
details.html
{% load rest_framework %}
<html><body>
<h1>Blog - {{ blogs.title }}</h1>
<form action="{% url 'blog_details' blogs.id %}" method="POST">
{% csrf_token %}
{% render_form serializer %}
<input type="submit" value="Save">
</form>
</body></html>
And it’s working 🙂
- [Answered ]-SSO implementation using djangosaml2
- [Answered ]-Display Word Count in Blog Post with Wagtail
Source:stackexchange.com