1
Ok, so with {% url view_name param1 param2 ... %}
you are passing arguments(param1, param2,โฆ) to your view. view_name is the name you defined for your view in the url
from urlpatterns
.
Therefore, you have to use this url:
url(r'^data/<product_type>/$', DataTable.as_view(), name='DataTable'),
Then, to catch this product_type
in your DataTable
, you have to implement the dispatch
method inside it:
def dispatch(self, request, *args, **kwargs):
self.product_type= kwargs.pop("product_type")
return super(LanguageMixin, self).dispatch(request, *args, **kwargs)
EDIT: Another way is to let the url
as you have and use GET
If you want to pass it as a GET parameter, then the best place to catch it is inside the get_context_method
:
def get_context_data(self, **kwargs):
expand_text = self.request.GET.get('product_type')
In order to catch it as a GET
parameter, you have to construct the URL properly, appending the GET parameters. Something like this:
<a href="{% url view_name %}?product_type={{ some_product_type }}">
Keep in mind that {% url view_name %}
only constructs a string, does not make a redirect