Django Academy · Ders

Alan Aramaları ve exclude()

contains, gte, in ve daha fazlasıyla sorgulayın.

2. ders / 413 adım

Alan Aramaları ve exclude(), 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.

Beyond Equality

Plain filters check for equality, but real queries need ranges and text matches. Field lookups unlock that extra power.

The Double Underscore

A lookup is the field name, a double underscore, then the operator. That tiny syntax is how Django reads richer conditions.

Book.objects.filter(year__gte=2020)

Greater and Less Than

Use gt, gte, lt, and lte for numeric or date ranges. They map straight to SQL comparison operators.

Book.objects.filter(price__lt=20)

Search Inside Text

The contains lookup finds rows where a field holds your substring anywhere inside it. Great for simple searches.

Book.objects.filter(title__contains="Python")

Ignore the Case

Add an i for case-insensitive text lookups like icontains or iexact, so capitals never trip up a match.

Book.objects.filter(title__icontains="python")

Starts and Ends

Match the edges of a string with startswith and endswith. Both have case-insensitive twins too.

Book.objects.filter(title__startswith="The")

Match a Set of Values

The in lookup keeps rows whose value appears in a list you pass. It is cleaner than chaining many OR checks.

Book.objects.filter(year__in=[2022, 2023, 2024])

Check for Empty Values

Use isnull to find rows where a column is NULL, or set it False to find the rows that have a value.

Book.objects.filter(summary__isnull=True)

Flip the Logic

Sometimes you want everything except a match. exclude() returns the rows that do NOT meet the condition.

Book.objects.exclude(published=True)

Lookups Work in exclude Too

Any field lookup that works in filter also works in exclude(). The only difference is the result is inverted.

Book.objects.exclude(year__gte=2020)

Combine filter and exclude

Chain both together to keep one group and drop another. Each call narrows the same lazy QuerySet further.

Book.objects.filter(published=True).exclude(price__gt=50)

Quick Check

You want books whose title holds "django" regardless of capitalization. Which lookup fits?

Recap

You leveled up! Field lookups use the double underscore for ranges and text, and exclude() flips any condition. 🔍

Başlamak ücretsiz

Yapay zeka eğitmeniyle Python öğren — ücretsiz

Tarayıcında gerçek kod yaz ve çalıştır, 7/24 yapay zeka eğitmeninden anında yardım al; web'de ya da uygulamada kaldığın yerden devam et.

Kurslar
30
Dersler
120

Sıkça Sorulan Sorular

“Alan Aramaları ve exclude()” dersi ücretsiz mi?

Evet — “Alan Aramaları ve exclude()” 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.

“Alan Aramaları ve exclude()” dersinde ne öğreneceğim?

contains, gte, in ve daha fazlasıyla sorgulayın. 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.

“Alan Aramaları ve exclude()” 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. all(), get() ve filter()
  2. Alan Aramaları ve exclude()
  3. order_by, Dilimleme ve Tembel Değerlendirme
  4. values, values_list ve count
← Django Academy Sayfasına Dön