ModelAdmin'ı Özelleştirme
list_display, list_filter ve search_fields ayarlarını yapın.
ModelAdmin'ı Özelleştirme, CoddyKit'te ücretsiz bir Django Academy dersidir. Bu, 4 dersinin 3. 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 the Defaults
The default admin works but feels plain. A ModelAdmin class lets you reshape how each model looks and behaves in the admin.
Subclass and Attach
Create a class that subclasses admin.ModelAdmin, then pass it when you register the model. That class holds all your tweaks.
class PostAdmin(admin.ModelAdmin):
pass
admin.site.register(Post, PostAdmin)Columns in the List
The list page shows one column by default. Set list_display to a tuple of field names and the admin renders each as a column.
list_display = ("title", "author", "created")Filter the Sidebar
Big tables get hard to scan. Add list_filter and the admin shows a sidebar to narrow rows by those fields fast. 🔍
list_filter = ("status", "created")Add a Search Box
Let staff hunt for records by text. Setting search_fields puts a search bar at the top that scans those fields.
search_fields = ("title", "author__name")Click to Edit
By default only the first column links to the edit page. Use list_display_links to choose which columns are clickable instead.
list_display_links = ("title",)Edit Inline in the List
Want to change a value without opening each row? Put a field in list_editable and you can edit it right on the list page.
list_editable = ("status",)Prefill the Slug
Slugs are tedious to type. The prepopulated_fields option fills a slug live from the title as you type it. ⚡
prepopulated_fields = {"slug": ("title",)}Order the Rows
Control the default sort with ordering. A leading minus sorts that field descending, so newest items can lead the list.
ordering = ("-created",)Group the Form
Long edit forms feel cluttered. Use fieldsets to split fields into labeled, collapsible sections on the edit page.
Computed Columns
list_display can also call a method on your admin class. That lets you show derived values, like a short preview of the body.
def short(self, obj):
return obj.body[:30]Quick Check
Which option controls the columns shown on the list page?
Recap
With ModelAdmin you added columns, filters, search, and sorting. A few attributes turn a plain table into a powerful data console. 🛠️
Sıkça Sorulan Sorular
“ModelAdmin'ı Özelleştirme” dersi ücretsiz mi?
Evet — “ModelAdmin'ı Özelleştirme” 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.
“ModelAdmin'ı Özelleştirme” dersinde ne öğreneceğim?
list_display, list_filter ve search_fields ayarlarını yapı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 3. dersidir.
“ModelAdmin'ı Özelleştirme” 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
- createsuperuser ve Oturum Açma
- Modelleri admin.site ile Kaydetme
- ModelAdmin'ı Özelleştirme
- Satır İçi Düzenleme ve Salt Okunur Alanlar