In the django doc the url function is like this
url(regex, view, kwargs=None, name=None, prefix='')
I have this
url(r'^download/template/(?P<object_id>\d+)/$', views.myview().myfunction,model=models.userModel, name="sample")
This is my view
class myview(TemplateView):
def myfunction(self,request, object_id, **kwargs):
model = kwargs['model']
I get this error
url() got an unexpected keyword argument 'model'
You are trying to pass in a model
keyword argument to the url()
function; you need to pass in a kwargs
argument instead (it takes a dictionary):
url(r'^download/template/(?P<object_id>\d+)/$', views.myview().myfunction,
kwargs=dict(model=models.userModel), name="sample")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With