'Make sure the response has the expected code, and if that isn\'t 204,
optionally check the correctness of a developer-facing message.'

def check_response(self, response, expected_code, expected_developer_message=None, expected_user_message=None):

    self.assertEqual(expected_code, response.status_code)
    if (expected_code == 204):
        self.assertIsNone(response.data)
    else:
        if (expected_developer_message is not None):
            self.assertEqual(response.data.get('developer_message'), expected_developer_message)
        if (expected_user_message is not None):
            self.assertEqual(response.data.get('user_message'), expected_user_message)
