0Pricing
Django Academy · Ders

ListView'da Sayfa Denetimleri

Şablonlara sonraki/önceki bağlantılarını ekleyin.

ListView'da Sayfa Denetimleri, CoddyKit'te ücretsiz bir Django Academy dersidir. Bu, 4 dersinin 2. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Django Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Django Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Pagination Built In

Good news: ListView can paginate for you. You barely write any code, and Django handles slicing the queryset into pages automatically. 🚀

Set paginate_by

Just add one attribute. Setting paginate_by tells the ListView how many items each page should show.

class ArticleList(ListView):
    model = Article
    paginate_by = 10

The page_obj Variable

With pagination on, your template receives a page_obj. It is the same Page object you met before, ready to loop and inspect.

Looping the Current Page

In the template, iterate page_obj to show only this page's items. Django already sliced the queryset for you.

{% for article in page_obj %}
  {{ article.title }}
{% endfor %}

Reading the Page Number

ListView pulls the page number from the ?page= query string in the URL, so a link to ?page=2 shows the second page.

Show a Previous Link

Guard the back link with has_previous so it only appears when there really is an earlier page to visit.

{% if page_obj.has_previous %}
  Prev
{% endif %}

Link to the Previous Page

Inside that block, build the href using previous_page_number so the link points one page back.

<a href="?page={{ page_obj.previous_page_number }}">Prev</a>

Show a Next Link

Mirror the logic for forward navigation. Wrap the next link in a has_next check so it hides on the final page.

{% if page_obj.has_next %}
  Next
{% endif %}

Display Page X of Y

Reassure users with a counter. Combine number and the paginator's num_pages to print "Page 2 of 5".

Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}

Custom Context Name

Prefer a friendlier loop variable? Set context_object_name and Django names the page list whatever you choose.

context_object_name = 'articles'

Putting It Together

One attribute plus a small template block gives you full page controls: prev, next, and a position counter, with no view logic to write.

Quick Check

Your ListView template needs the current page's items.

Recap

You enabled pagination with paginate_by, looped page_obj, and built prev/next links guarded by has_previous and has_next. Clean lists, zero view code. 🎉

Sıkça Sorulan Sorular

“ListView'da Sayfa Denetimleri” dersi ücretsiz mi?

Evet — “ListView'da Sayfa Denetimleri” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Django Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Django Academy kursu toplamda 4 dersten oluşur.

“ListView'da Sayfa Denetimleri” dersinde ne öğreneceğim?

Şablonlara sonraki/önceki bağlantılarını ekleyin. Django Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Django Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Django Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 2. dersidir.

“ListView'da Sayfa Denetimleri” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Django Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Django Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Paginator Sınıfı
  2. ListView'da Sayfa Denetimleri
  3. TestCase ve Doğrulamalar Yazma
  4. Test İstemcisi ve Test Verileri
← Django Academy Sayfasına Dön