title: Django and backbone - how to write a view which supports loading elements by ajax and non-ajax for disabled javascript
body: <p>I've been wondering how to develop a django view which supports loading objects trough json and also for clients with blocked js it should support non-js fallback - use querysets like ObjectName.objects.filter()</p>
  
  <p>What's the best approach for such views which support dynamic data loading by json and also getting objects without json? Or simply my approach is totally wrong and I should get some more information how to write a ajax-dynamic site like <a href="http://www.usatoday.com" rel="nofollow noreferrer">http://www.usatoday.com</a></p>
  
  <pre><code>def index(request):
      q = Page.objects.all()
      return TemplateResponse(request, "orders/order_index.html",
                                  {'object_list': q,},)
  </code></pre>
  
  <p>If you need any additional data connected with my question please just ask me.</p>
  
  <p>Update 1 - example:</p>
  
  <p>Index renders initial page you see when you enter the site (example.com)</p>
  
  <pre><code>def index(request):
      q = Entry.objects.all().order_by('-id')
      return TemplateResponse(request, 'index.html', {'object_list': q, })
  
  
  def detail(request, slug):
      q = get_object_or_404(Entry.objects.all(), slug=slug)
      return TemplateResponse(request, 'blog/templates/blog_detail.html', {'object': q, })
  </code></pre>
  
  <p>index.html</p>
  
  <pre><code>{% extends "base.html" %}
  {% load webdesign %}
  {% load markup %}
  {% load humanize %}
  {% load endless %}
  {% load i18n %}
  
  {% block content %}
      {% paginate object_list %}
      {% for object in object_list %}
          &lt;article&gt;
  
              &lt;h2&gt;{{ object.title }}&lt;/h2&gt;
  
              &lt;div&gt;
  
              &lt;/div&gt;
              &lt;hr&gt;
              &lt;p&gt;
                  {{ object.get_short_text|markdown }}
              &lt;/p&gt;
  
              &lt;div class="clearfix"&gt;&lt;/div&gt;
              &lt;div class="row"&gt;
                  &lt;div class="large-6 columns"&gt;
                      &lt;span class="metadata"&gt;&lt;i class="foundicon-clock"&gt;&lt;/i&gt; {{ object.date_added|date:"j E Y" }} ({{ object.date_added|naturaltime }})&lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;a class="button expand read_more" href="{{ object.get_absolute_url }}"&gt;{% trans "Read more" %}&lt;/a&gt;
              &lt;hr&gt;
  
          &lt;/article&gt;
      {% endfor %}
      {% show_pages %}
  {% endblock %}
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/RYNla.png" alt="enter image description here"></p>
  
  <pre><code>non ajax
  [16/Mar/2013 15:16:52] "GET / HTTP/1.1" 200 2275
  [16/Mar/2013 15:16:52] "GET /site_media/static/sass/style.css HTTP/1.1" 304 0
  [16/Mar/2013 15:16:52] "GET /site_media/static/foundicons/foundation_icons_general/stylesheets/general_foundicons.css HTTP/1.1" 304 0
  [16/Mar/2013 15:16:52] "GET /site_media/static/foundation/js/vendor/custom.modernizr.js HTTP/1.1" 304 0
  [16/Mar/2013 15:16:52] "GET /site_media/static/foundation/js/vendor/zepto.js HTTP/1.1" 304 0
  [16/Mar/2013 15:16:52] "GET /site_media/static/foundation/js/foundation.min.js HTTP/1.1" 304 0
  [16/Mar/2013 15:16:52] "GET /site_media/static/img/logo.png HTTP/1.1" 304 0
  [16/Mar/2013 15:16:52] "GET /site_media/static/img/navy_blue_min.png HTTP/1.1" 304 0
  [16/Mar/2013 15:16:52] "GET /site_media/static/img/sub.png HTTP/1.1" 304 0
  [16/Mar/2013 15:16:52] "GET /site_media/static/foundicons/foundation_icons_general/fonts/general_foundicons.woff HTTP/1.1" 304 0
  [16/Mar/2013 15:16:52] "GET / HTTP/1.1" 200 14
  index
  ajax
  </code></pre>