Answer the question
In order to leave comments, you need to log in
Why doesn't django templates have something like a built-in set tag? And what to replace it with?
In order to maximize the separation of views and templates, sometimes you want django templates to have something like declaring an internal (inside the template) variable. For example, if some template block is used repeatedly. For example, in this piece:
<input type="text"
class="form-control"
value="{{ APP_INVITATION_STRING_IN_FORM }}"
id="fio"
autocomplete="on"
onfocus="if(this.value=='{{ APP_INVITATION_STRING_IN_FORM }}'){
this.value='';
this.style.color='#000';
}"
onblur= "if(this.value==''){this.value='{{ APP_INVITATION_STRING_IN_FORM }}';
this.style.color='#777';
}"
/>
Answer the question
In order to leave comments, you need to log in
Docks rule, yes.
https://docs.djangoproject.com/en/1.8/ref/template...
You should not store or set anything in templates - there is the last place for this
. Set the variable better in settings.py
<input type="text"
class="form-control"
value="{{ APP_INVITATION_STRING_IN_FORM }}"
id="fio"
autocomplete="on"
placeholder="{{ APP_INVITATION_STRING_IN_FORM }}"
<!--
ВТФ!???
onfocus="if(this.value=='{{ APP_INVITATION_STRING_IN_FORM }}'){
this.value='';
this.style.color='#000';
}"
onblur= "if(this.value==''){this.value='{{ APP_INVITATION_STRING_IN_FORM }}';
this.style.color='#777';
}" -->
>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question