title: How do I add Pagination to a table (Django)
body: <p>I am trying to <strong>add pagination to one of the tables</strong> for my project, but I can't find any good resources to refer to, all of the docs use some kind of URL query, but I don't want to do that, since it is on the user page.</p>
  <p><strong>Background</strong> --- I am making a mock website for trading for a project and I need the user to be able to see their trade history, and as you can imagine, after any more than 10, the page starts to look very long, so I am trying to find a way to make the table have pages, but I just can't figure it out.</p>
  <p><strong>Aim</strong> -- To add pages to a bootstrap table. The table should be able to go back and forth using buttons.</p>
  <p><strong>My &quot;solution&quot;</strong> - after going through stuff for about an hour, I found <a href="https://datatables.net/" rel="nofollow noreferrer">this</a> but I don't know if it is good/safe.</p>
  <p><strong>Code :</strong>
  VIEW -</p>
  <pre><code>def userPage(request):
      user = request.user
      user_info = user.info
      trades = user_info.trade_set.all().order_by('-time_bought_at') ###I want this queryset to be paginated
      total_trades = trades.count()
      balance = round(user_info.balance)
      
      context = {
          &quot;user&quot; : user,
          &quot;user_info&quot; : user_info,
          &quot;trades&quot; : trades,
          &quot;total_trades&quot; : total_trades,
          &quot;balance&quot; : balance,        
          }
      return render(request, &quot;accounts/user.html&quot;, context)
  </code></pre>
  <p>I render it as :
  this is the table that I want to paginate :)</p>
  <pre><code>&lt;div class=&quot;row&quot;&gt;
          &lt;div class=&quot;card card-body&quot;&gt;
              &lt;table class=&quot;table table-sm&quot;&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Stock&lt;/th&gt;
                      &lt;th&gt;Action&lt;/th&gt;
                      &lt;th&gt;Price&lt;/th&gt;
                      &lt;th&gt;No. of Stocks&lt;/th&gt;
                      &lt;th&gt;Total Cost of Trade&lt;/th&gt;
                      &lt;th&gt;Time of Purchase&lt;/th&gt;
                      &lt;th&gt;Balance&lt;/th&gt;
                  &lt;/tr&gt;
                  {% for trade in trades %}
                  &lt;tr&gt;
                      &lt;td&gt;{{trade.ticker}}&lt;/td&gt;
                      &lt;td&gt;{{trade.action}}&lt;/td&gt;
                      &lt;td&gt;{{trade.price_trade_at}}&lt;/td&gt;
                      &lt;td&gt;{{trade.stocks_bought}}&lt;/td&gt;
                      &lt;td&gt;{{trade.cost_of_trade}}&lt;/td&gt;
                      &lt;td&gt;{{trade.time_bought_at}}&lt;/td&gt;
                      &lt;td&gt;{{trade.balance_of_trader_after_purchase}}&lt;/td&gt;
                  &lt;/tr&gt;
                  {% endfor %}
              &lt;/table&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p>Please point me in the correct direction, I got no clue.</p>