File tree Expand file tree Collapse file tree 1 file changed +11
-14
lines changed
Expand file tree Collapse file tree 1 file changed +11
-14
lines changed Original file line number Diff line number Diff line change @@ -658,10 +658,10 @@ impl Render for Tag {
658658 Some ( token) => {
659659 let bound_token = token. bind ( py) ;
660660 if bound_token. is_truthy ( ) . unwrap_or ( false ) {
661- let token_str = bound_token. to_string ( ) ;
662- if token_str == "NOTPROVIDED" {
661+ if bound_token. eq ( "NOTPROVIDED" ) {
663662 Cow :: Borrowed ( "" )
664663 } else {
664+ let token_str = bound_token. str ( ) ?;
665665 Cow :: Owned ( format ! (
666666 r#"<input type="hidden" name="csrfmiddlewaretoken" value="{}">"# ,
667667 html_escape:: encode_quoted_attribute( & token_str)
@@ -672,20 +672,17 @@ impl Render for Tag {
672672 }
673673 }
674674 None => {
675- let debug = py
676- . import ( "django.conf" )
677- . and_then ( |conf| conf. getattr ( "settings" ) )
678- . and_then ( |settings| settings. getattr ( "DEBUG" ) )
679- . and_then ( |debug| debug. is_truthy ( ) )
680- . unwrap_or ( false ) ;
675+ let debug = py
676+ . import ( "django.conf" ) ?
677+ . getattr ( "settings" ) ?
678+ . getattr ( "DEBUG" ) ?
679+ . is_truthy ( ) ?;
681680
682681 if debug {
683- if let Ok ( warnings) = py. import ( "warnings" ) {
684- let _ = warnings. call_method1 (
685- "warn" ,
686- ( "A {% csrf_token %} was used in a template, but the context did not provide the value. This is usually caused by not using RequestContext." , )
687- ) ;
688- }
682+ py. import ( "warnings" ) ?. call_method1 (
683+ "warn" ,
684+ ( "A {% csrf_token %} was used in a template, but the context did not provide the value. This is usually caused by not using RequestContext." , )
685+ ) ?;
689686 }
690687
691688 Cow :: Borrowed ( "" )
You can’t perform that action at this time.
0 commit comments