title: If else statement not working in ajax template
body: <p>title_posts.html   </p>
  
  <pre><code>{% extends "main/base.html" %}
  {% load static %}
  {% load humanize %}
  {% block styles %}
      &lt;link rel="stylesheet" type="text/css" href="{% static 'main/css/title_posts.css' %}"&gt;
  {% endblock styles %}
  
  {% block content %}
      &lt;style&gt;
          body {
              background-image: url("{{ game.cover_display.url }}");
              background-repeat: no-repeat;
              background-size: 100% auto;
              background-color: #171717;
              background-attachment: fixed;
              background-position: 0 3.5rem;
          }
      &lt;/style&gt;
      &lt;div class="container black2 container-nav gamenav"&gt;
          &lt;ul class="quantico"&gt;
              &lt;li&gt;&lt;a class="text-light nav-link" href="{% url 'title-posts' game.title %}"&gt;Updates&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="text-light nav-link" href="{% url 'title-bugs' game.title %}"&gt;Bugs&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="text-light nav-link" href="https://twitter.com/{{ game.twitter }}"&gt;Twitter&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="text-light nav-link" href="https://www.reddit.com/r/{{ game.reddit }}"&gt;Reddit&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
      &lt;div class="container black container-position"&gt;
          &lt;div class="row justify-content-center"&gt;
              &lt;div class="col-md-3 text-center"&gt;
                  &lt;img class="cover-image-height" src="{{ game.cover.url }}"&gt;
              &lt;/div&gt;
              &lt;div class="col-md-9"&gt;
                  &lt;p&gt;{{ game.description| safe }}&lt;/p&gt;
                  &lt;div class="btn-group"&gt;
                      &lt;button type="button" id="platform" class="btn btn-primary dropdown-toggle" data-toggle="dropdown"
                              aria-haspopup="true" aria-expanded="false"&gt;
                          Select Platform
                      &lt;/button&gt;
                      &lt;div class="dropdown-menu" id="plat-form-options"&gt;
                          {% for platform in game.platform.all %}
                              &lt;option class="dropdown-item" value="{{ platform.id }}"
                                      onclick="platFormSelect('{% url 'title-posts-ajax' title=game.title platform_id=platform.id %}', '{{ platform }}')"&gt;{{ platform }}&lt;/option&gt;
                          {% endfor %}
                      &lt;/div&gt;
                  &lt;/div&gt;
  
  
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;hr&gt;
          &lt;div id="posts_data"&gt;
          &lt;/div&gt;
          {% if is_paginated %}
  
              {% if page_obj.has_previous %}
                  &lt;a class="btn btn-outline-info mb-4" href="?page=1"&gt;First&lt;/a&gt;
                  &lt;a class="btn btn-outline-info mb-4" href="?page={{ page_obj.previous_page_number }}"&gt;Previous&lt;/a&gt;
              {% endif %}
  
              {% for num in page_obj.paginator.page_range %}
                  {% if page_obj.number == num %}
                      &lt;a class="btn btn-info mb-4" href="?page={{ num }}"&gt;{{ num }}&lt;/a&gt;
                  {% elif num &gt; page_obj.number|add:'-3' and num &lt; page_obj.number|add:'3' %}
                      &lt;a class="btn btn-outline-info mb-4" href="?page={{ num }}"&gt;{{ num }}&lt;/a&gt;
                  {% endif %}
              {% endfor %}
  
              {% if page_obj.has_next %}
                  &lt;a class="btn btn-outline-info mb-4" href="?page={{ page_obj.next_page_number }}"&gt;Next&lt;/a&gt;
                  &lt;a class="btn btn-outline-info mb-4" href="?page={{ page_obj.paginator.num_pages }}"&gt;Last&lt;/a&gt;
              {% endif %}
  
          {% endif %}
      &lt;/div&gt;
  
  
  
      &lt;script&gt;
  
  
          $(document).ready(function () {
              if ($("#plat-form-options option").length &gt; 0) {
                  $("#plat-form-options option")[0].click();
              }
  
          });
  
  
          function platFormSelect(url, platform) {
              $('#platform').text(platform);
  
  
              $.get(url, function (response) {
                          $('#posts_data').html(response);
  
                      })
                      .done(function () {
  
                      })
                      .fail(function () {
  
                      });
  
          }
  
  
      &lt;/script&gt;
  {% endblock content %}
  </code></pre>
  
  <p>post_ajax.html:
  This gets inserted into the title_posts.html at div id="posts_data".</p>
  
  <pre><code>{% if user.is_superuser %}
      {% for post in posts %}
          &lt;div class="row"&gt;
              &lt;div class="col-10"&gt;
                  &lt;article class="media content-section"&gt;
                      &lt;div class="media-body"&gt;
                          &lt;h2 class="article-title"&gt;{{ post.article_title }}&lt;/h2&gt;
                          &lt;div class="article-content"&gt;{{ post.content|safe }}&lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/article&gt;
              &lt;/div&gt;
              &lt;div class="col-2 post-menu"&gt;
                  &lt;a class="btn btn-primary" href="#" aria-label="Edit"&gt;
                      &lt;i class="fas fa-edit" aria-hidden="true"&gt;&lt;/i&gt;
                  &lt;/a&gt;
                  &lt;a class="btn btn-danger" href="#" aria-label="Delete"&gt;
                      &lt;i class="far fa-trash-alt"&gt;&lt;/i&gt;
                  &lt;/a&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;hr&gt;
      {% endfor %}
  {% else %}
      {% for post in posts %}
          &lt;div class="row"&gt;
              &lt;article class="media content-section"&gt;
                  &lt;div class="media-body"&gt;
                      &lt;h2 class="article-title"&gt;{{ post.article_title }}&lt;/h2&gt;
                      &lt;div class="article-content"&gt;{{ post.content|safe }}&lt;/div&gt;
                  &lt;/div&gt;
              &lt;/article&gt;
          &lt;/div&gt;
          &lt;hr&gt;
      {% endfor %}
  {% endif %}
  </code></pre>
  
  <p>My post_ajax.html has an if else statement that does not trigger for if user.is_superuser even though I am logged in as superuser. I've tested this on the title_posts.html and it trigger but not on the post_ajax.html</p>
  
  <p>Edit: </p>
  
  <p>views.py</p>
  
  <pre><code>class TitlePostAjaxListView(ListView):
      model = Post
      template_name = 'main/posts_ajax.html'
      context_object_name = 'posts'
      paginate_by = 5
  
      def get_queryset(self):
          title = get_object_or_404(Game, title=self.kwargs.get('title'))
          return Post.objects.filter(game=title, platform=Platform.objects.filter(
              id=self.kwargs.get('platform_id')).first()).order_by('-date_published')
  
      def get_context_data(self, **kwargs):
          context = super(TitlePostAjaxListView, self).get_context_data(**kwargs)
          context['game'] = get_object_or_404(Game, title=self.kwargs.get('title'))
  
          return context
  
      def get(self, request, *args, **kwargs):
          self.object_list = self.get_queryset()
          context = self.get_context_data()
          return HttpResponse(render_to_string(self.template_name, context))
  </code></pre>