との2つの試験:ジャンゴTemplateSyntax:私は2つのテストを実行しようとしています '..場合、または...'
{!%をprofile.id = 100またはprofile.location == NULLの場合%}しかし、うまくいかないようです。私はドキュメントでこれがなぜ機能していないのか見当たりませんでした。何か案は?
EDIT:SQL DBに
、profile.locationの値がNULLです。レンダリングされた結果はNoneです。
編集2:
ここは完全なチェーンです。ユーザーの場所を取得する4つの方法があります。あなたが見ることができるように、それは何のNULL
はありません...
{% if profile.city.id != 104 or profile.city %}
{{profile.city}}
{% else %}
{% if profile.mylocation != '' %}
{{ profile.mylocation }}
{% else %}
{% if profile.fbconnect == 1 and profile.location != '' and profile.location != "None" %}
{{profile.location}}
{% else %}
{% if profile.sglocation.city %}{{profile.sglocation.city}}{% else %}{{profile.sglocation.country}}{% endif %}
{% endif %}
{% endif %}
{% endif %}
感謝答えのためのクリス。私はまだ「なし」と表示されています。 – Emile
まず、 'profile.location ==" None "'はテストできません。 'None'は文字列ではなく、あなたのテンプレートでそのままレンダリングしています。単に変数名だけで変数の存在をテストすることができます。たとえば、{%if profile.location%} {{profile.location}} {%endif%} –
実際にはそのインスタンスは文字列です。 Facebookはたまにあなたに "None"の文字列を与えて、そのテストの理由です。 – Emile