title: How to change an existing variable in a django template
body: <p>Newish to Django here and need some assistance. I have a bool variable empty=True. I passed the variable through views to my template successfully. In the template I have a while loop that includes an if/else statement. I need to be able to change my variable to False if it meets a condition in the if statement. Once I'm out of the loop there is another if/else statement to check in empty is True.</p>
  
  <p>I can't seem to figure out how to change a variable in the template. </p>
  
  <p>I did try a with statement to change the variable but it didn't work correctly for me because I have to end the with statement before the loop ends. Once the with statement ends, the variable reverts back to its' original value</p>
  
  <p>Views -
  '''</p>
  
  <pre><code>def myProjects(request):
      user = request.user
      projects = Project.objects.all() #from db
      empty=True
      return render(request,'users/myProjects.html',locals())
  </code></pre>
  
  <p>'''
  Template - 
  '''</p>
  
  <pre><code>&lt;div class="row" id="main1"&gt;
    &lt;div class="col-2"&gt;&lt;/div&gt;
    &lt;div class="col-9"&gt;
      &lt;div&gt;
        &lt;h1&gt;My Projects: &lt;/h1&gt;
        {% for x in proj %}
          {% if x.creator.user == me %}
            &lt;div class="media1"&gt;
              &lt;img class="account-img" src="{{x.projectPicture.url}}"&gt;
              &lt;div&gt;
                &lt;h5&gt;&lt;strong&gt;Project Name: {{x.projectName}}&lt;/strong&gt;&lt;/h5&gt;
                &lt;p&gt;Project Type: {{x.projectType}}&lt;/p&gt;
                &lt;p&gt;Creator: &lt;a href="/allUsers?name1={{x.creator.user}}"&gt; {{x.creator.user}} &lt;/a&gt;&lt;/p&gt;
                &lt;p class="text-muted small"&gt;Created: {{x.dateTime}}&lt;/p&gt;
              &lt;/div&gt;
            &lt;/div&gt;
            {{empty=False}}
          {% else %}
            {{pass}}
          {% endif %}
  
        {% if empty==True %}
          &lt;p&gt;You do not have any projects&lt;/p&gt;
        {% else %}
          {{pass}}
        {% endif %}
        {% endfor %}
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  {% endblock%}
  </code></pre>
  
  <p>'''</p>