[Django]-How do I pass a PK or slug to a DetailView using RequestFactory in Django?

66👍

Thanks to the #django channel on Freenode IRC, I found the following method is the correct one to pass parameters all the way through to the view:

response = DeviceView.as_view()(request, pk=1)

I hope this helps somebody else attempting to use RequestFactory to test DetailView or DeleteView etc

👤Mazzy

Leave a comment