We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
根据书中示例代码,在Django 1.7版本中,做单元测试时不需要关心csrf_token的生成问题。但在1.9版本中,执行单元测试代码则csrf_token没有被自动生成,render_to_string根本没有对其进行绘制。
根据http://s1n4.github.io/2013/05/12/django-csrf_token-when-using-render_to_string/ ,解决代码如下:
c = {} c.update(csrf(request)) expected_html = render_to_string( 'home.html', c ) self.assertEqual(response.content.decode(), expected_html)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
根据书中示例代码,在Django 1.7版本中,做单元测试时不需要关心csrf_token的生成问题。但在1.9版本中,执行单元测试代码则csrf_token没有被自动生成,render_to_string根本没有对其进行绘制。
根据http://s1n4.github.io/2013/05/12/django-csrf_token-when-using-render_to_string/ ,解决代码如下:
The text was updated successfully, but these errors were encountered: