1
You have to send the user’s id.
This might work :
add_member_post = self.client.post(reverse('add_member',
kwargs={'pk':station.pk}),
{'user':user2.id},
follow=True)
And check if the request actually worked :
self.assertEqual(add_member_post.status_code, 200)
0
station
remains the instance you created inside the test, and is not affected by anything that happens in your view. You’d need to reload it from the database:
self.client.post(...)
station = Station.objects.get(pk=station.pk)
self.assertIn(...)
- [Answer]-Is it possible to ignore a system check error in Django 1.7+
- [Answer]-TypeError: __init__() got an unexpected keyword argument 'image_field'
- [Answer]-AttributeError when establishing a foreign key using the to_field option
- [Answer]-ObtaI n url of page which fired ajax request in ajax view
- [Answer]-Easiest way to concatenate two QuerySets same Model (no order needed)
Source:stackexchange.com