title: Django - Datatables ajax error with rest framework
body: <p>I'm trying to use rest in conjunction with <a href="https://www.datatables.net/" rel="nofollow noreferrer">Datatables</a>  to display a large list with server-side processing. On the datatable html template i get an empty table with an error</p>
  <blockquote>
  <p>&quot;DataTables warning: table id=bib - Ajax error. For more information
  about this error, please see <a href="http://datatables.net/tn/7%22" rel="nofollow noreferrer">http://datatables.net/tn/7&quot;</a>.</p>
  </blockquote>
  <p>urls.py</p>
  <pre><code>from . import views as v
  from rest_framework import routers
  
  router = routers.DefaultRouter()
  router.register(r'Bibrest51', v.BibViewSet)
  
  urlpatterns = [
      path('home/', include(router.urls)),
      
      path('home/', v.home, name='home'),
      path('', v.home, name='home'),
  </code></pre>
  <p>views.py</p>
  <pre><code>class Get_bib(viewsets.ModelViewSet):
      queryset = Bibrest51.objects.all()
      serializer_class = BibSerializer
  </code></pre>
  <p>home.html</p>
  <pre><code>&lt;table id=&quot;bib&quot; class=&quot;table table-striped table-bordered&quot; style=&quot;width:100%&quot; data-server-side=&quot;true&quot; 
          data-ajax=&quot;/home/Bibrest51/?format=datatables&quot;&gt;
     &lt;thead&gt;
        &lt;tr&gt;
           &lt;th data-data=&quot;autor&quot; class =&quot;text-center all&quot;&gt;Autor&lt;/th&gt;
           &lt;th data-data=&quot;ano&quot; class =&quot;text-center all&quot;&gt;Ano&lt;/th&gt;
           &lt;th&gt;Título&lt;/th&gt;
           &lt;th data-data=&quot;tipo&quot; class =&quot;text-center not-mobile&quot;&gt;Tipo&lt;/th&gt;
           &lt;th data-data=&quot;tema&quot; class =&quot;text-center not-mobile&quot;&gt;Tema&lt;/th&gt;
        &lt;/tr&gt;
     &lt;/thead&gt;
     &lt;tbody&gt;
   
     &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  <p>JS:</p>
  <pre><code> &lt;script&gt;
          $(document).ready(function() {
            $('#bib').DataTable();
        });
    
    &lt;/script&gt;
  </code></pre>
  <p>models.py</p>
  <pre><code>class Bibrest51(models.Model):
      cadastro_id = models.AutoField(primary_key=True)
      autor = models.CharField(db_column='Autor', max_length=255)
      ano = models.CharField(db_column='Ano', max_length=255)
      titulo = models.CharField(db_column='Titulo', max_length=255)
      referencia = models.CharField(db_column='Referencia', max_length=255)
  
  
  </code></pre>
  <p>serializers.py</p>
  <pre><code>from rest_framework import serializers
  from .models import Bibrest51
  
  class BibSerializer(serializers.ModelSerializer):
      class Meta:
          model = Bibrest51
          fields = ['autor', 'ano','tipo','tema']
  </code></pre>