我有一個 HTML 鏈接,點擊后會將我定向到相應的鏈接
<div onclick="location.href='{% url 'newscountry' 'Kuwait' %}'">
Kuwait
</div>
但是我被警告要按照所附圖片添加;上面的鏈接(作為{% url 'newscountry'; 'Kuwait' %}')。
urls.py 如下,
path('country/<str:country>/',NewsCountryView.as_view(),name='newscountry'),
視圖.py
class NewsCountryView(ListView):
model = News
template_name = 'newsfront/index.html' # <app>/<model>_<viewtype>.html
context_object_name = 'news'
ordering = ['-date_posted']
paginate_by = 16
def get_queryset(self):
country=self.kwargs.get('country')
return News.objects.filter(country=country)

uj5u.com熱心網友回復:
只需為 VSCode安裝Django 擴展,它就會消失。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/400918.html
標籤:姜戈
上一篇:我的網站在我執行collectstatic之前一直顯示CSS-Django
下一篇:djangojson回應問題
