मुझे एक विस्तार दृश्य प्रदर्शित करने के लिए मेरे यूआरएल को कॉन्फ़िगर करने में समस्या हो रही है। इस लिंक पर क्लिक करके: <a href='{% url blog_detail blog.slug %}'>{{ blog.name }}</a>
blog.html
दिखाता है, जब मैंने सोचा कि यह blog-detail.html
दिखाएगा। कोई त्रुटि नहीं है और ब्राउजर बार कहता है: example.com/blog/the-slug
, अभी भी blog.html
से एचटीएमएल प्रदर्शित करता है, blog-detail.html
नहीं। कोई विचार क्यों? आपके विचारों के लिए धन्यवाद।Django Url, विवरण के लिए स्लग पृष्ठ
यूआरएल:
url(r'^blog/', 'myapp.views.blog', name='blog'),
url(r'^blog/(?P<slug>[\w-]+)/$', 'myapp.views.blog_detail', name='blog_detail'),
विचार:
def blog(request):
blog_list = Blog.objects.all()
return render(request, 'blog.html', {'blog_list':blog_list})
def blog_detail(request, slug):
blog = get_object_or_404(Blog, slug=slug)
return render(request, 'blog-detail.html', {'blog':blog})
संपादित करें: उत्पादन से @omouse
का अनुरोध इस लिंक पर क्लिक करने से उत्पादन होता है। यह बिल्कुल blog.html
जैसा ही है, लेकिन यह blog-detail.html
होना चाहिए। Argggg!
<div id='content-wrapper'>
<section>
<div class='blog-name'><h2><a href='/blog/test/'>Test</a></h2></div>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a ...
<div class='blog-name'><h2><a href='/blog/second-test/'>Second Test</a></h2></div>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a ...
</section>
</div>
पहले से ही इस एक {{ blog.name }} – catherine
हाँ कोशिश है कि धन्यवाद की कोशिश की। अभी भी कोई भाग्य नहीं है। सुनिश्चित नहीं है कि समस्या क्या हो सकती है ... –
क्या आप टेम्पलेट आउटपुट जोड़ सकते हैं? –