2๐
โ
You will find this function useful(found here):
def setup_view(view, request, *args, **kwargs):
"""Mimic as_view() returned callable, but returns view instance.
args and kwargs are the same you would pass to ``reverse()``
"""
view.request = request
view.args = args
view.kwargs = kwargs
return view
You can use it like this:
view = setup_view(
views.DynamicStorageDownloadView(),
django.test.RequestFactory().get('/fake-url'),
path='dummy path')
path = view.get_path()
self.assertEqual(path, 'DUMMY PATH')
๐คSebastian Wozny
0๐
Looks like as_view() return function, but not an object.
Could you please try this code?
view = SnippetList.as_view()(request)
๐คPaul
- [Answered ]-FormSet saves the data of only one form
- [Answered ]-Password reset in Django-registration can't find site.domain
Source:stackexchange.com