Home > Enterprise >  URL warning in Django template, being asked to add semicolon in the url link object
URL warning in Django template, being asked to add semicolon in the url link object

Time:01-02

I have an HTML link, upon clicking it will direct me to the respective link

<div onclick="location.href='{% url 'newscountry' 'Kuwait' %}'">
      Kuwait
    </div>

But I am being warned to add ; in the above link (as {% url 'newscountry'; 'Kuwait' %}')as per the attached image.

urls.py as below,

   path('country/<str:country>/',NewsCountryView.as_view(),name='newscountry'),

views.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)

enter image description here

CodePudding user response:

Just install the Django extension for VSCode and it will perish.

  • Related