在views.pyDjango的網址添加參數
class LaViewSet(viewsets.ModelViewSet):
serializer_class = IlSerializer
def get_queryset(self):
ilfiltro = self.kwargs['miopar']
return models.Pippo.objects.filter(pippo=ilfiltro)
在url.py
url(r'^pippo/(?P<miopar>.+)', views.LaViewSet.as_view({'get': 'list'}), name="Serializzata"),
這是一個工作URL:
http://127.0.0.1:8000/pippo/1
但如果我放入模板:
{% url '1' 'Serializzata' %};
或
{% url 'Serializzata'?1 %};
保持收到此錯誤:
TemplateSyntaxError: Could not parse the remainder: '?1' from ''Serializzata'?1'