Beatriz Negreiros
Beatriz Negreiros

Reputation: 21

Pagination from django_tables2 not rendering

I am relatively new in Django and could not find any answer here on why my table from django_tables2 is not rendering nice pagination buttons. Here follows the codes:

models.py

class IDOC(models.Model):
    on_delete=models.SET_NULL, null=True)
    sample_id = models.CharField(max_length=200)
    lon = models.FloatField(null=True, blank=True)
    lat = models.FloatField(null=True, blank=True)
    dp_position = models.IntegerField(null=True, blank=True, verbose_name='DP Position [-]')

    def __str__(self):
        return self.sample_id

tables.py

class IDOCTable(tables.Table):
    sediment_depth_m = NumberColumn()
    wl_m = NumberColumn()
    H_m = NumberColumn()
    idoc_mgl = NumberColumn()
    temp_c = NumberColumn()
    idoc_sat = NumberColumn()

    class Meta:
        model = IDOC
        template_name = "django_tables2/bootstrap-responsive.html"

views.py

def view():
    idoc_objects = IDOC.objects.all()
    idoc_show = flutb.IDOCTable(idoc_objects)
    context = {
               'idoc_table': idoc_show,
               }
    return render(request, 'flussdata/query.html', context)

flussdata/query.html

{% extends 'base.html' %}
{% load django_tables2 %}

{% block content %}
<div class="row">
    <div class="col-md">
        <div class="row">
            <div class="card card-body">
                <h3>Intragravel Dissolved Oxygen Content</h3>
                {% render_table idoc_table %}
            </div>
        </div>     
    </div>   
</div>

Then, my tables is rendered like this: enter image description here

Instead of the way it should, which I believe is like this:

enter image description here

Upvotes: 1

Views: 536

Answers (1)

Christian Ayala
Christian Ayala

Reputation: 1

Try using another template, use "django_tables2/bootstrap4.html" instead of "django_tables2/bootstrap-responsive.html"

Upvotes: 0

Related Questions