0Pricing
Django Academy · Ders

URL Parametrelerini Yakalama

int ve slug gibi yol dönüştürücülerini görünümlerde okuyun.

URL Parametrelerini Yakalama, 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.

Why Capture Parameters

Many pages depend on a value in the URL, like a product id. Django lets you capture that value and pass it straight to your view.

Angle Bracket Syntax

You capture a piece of the URL with angle brackets. Whatever is inside becomes a named argument for your view.

path('post/<int:id>/', views.detail)

Converters Set the Type

The word before the colon is a converter. It both matches a pattern and converts the captured text to the right Python type.

The int Converter

The int converter matches digits and hands your view a real integer, not a string. Perfect for numeric ids.

path('post/<int:id>/', views.detail)

The slug Converter

The slug converter matches letters, numbers, hyphens, and underscores. It is ideal for readable, SEO-friendly URLs.

path('blog/<slug:title>/', views.post)

The View Receives the Value

The captured name becomes a parameter in your view, right after request. The names must match exactly.

def detail(request, id):
    return HttpResponse('Post ' + str(id))

Names Must Match

The name in the URL and the view argument must be identical. If the URL says id, your view must accept id too.

More Built-in Converters

Beyond int and slug, Django ships str, uuid, and path converters. Each matches a different shape of value.

str Is the Default

If you skip the converter, Django uses str. It matches any text except a slash, which keeps segments separate.

path('user/<username>/', views.profile)

Capturing Multiple Values

You can capture several values in one route. Each becomes its own keyword argument in the view, in order.

path('<int:year>/<int:month>/', views.archive)

Wrong Type, No Match

If a URL value does not fit the converter, the route simply does not match. Django moves on or returns a 404.

Quick Check

Consider which converter fits a numeric id.

Recap: Dynamic URLs

Use angle brackets with a converter to capture URL values. The view receives them by name, typed and ready to use. ✨

Sıkça Sorulan Sorular

“URL Parametrelerini Yakalama” dersi ücretsiz mi?

Evet — “URL Parametrelerini Yakalama” 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.

“URL Parametrelerini Yakalama” dersinde ne öğreneceğim?

int ve slug gibi yol dönüştürücülerini görünümlerde okuyun. 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.

“URL Parametrelerini Yakalama” 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. İşlev Tabanlı Görünüm Yazma
  2. path() ile URL Desenleri
  3. URL Parametrelerini Yakalama
  4. Uygulama URL'lerini Dahil Etme ve Rotaları Adlandırma
← Django Academy Sayfasına Dön