0Pricing
Django Academy · Ders

path() ile URL Desenleri

urls.py içinde bir URL'yi görünüme bağlayın.

path() ile URL Desenleri, 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.

Why URLs Need Mapping

Django needs to know which view handles which address. The URLconf is the map that connects a URL to a view.

The urls.py File

Your URL map lives in urls.py. It holds a list called urlpatterns that Django checks top to bottom for a match.

Importing path

The main tool for routing is the path function. Import it from django.urls at the top of the file.

from django.urls import path

Anatomy of path()

The path function takes a route string and the view to call. You list these inside the urlpatterns list.

path('about/', views.about)

A Complete urlpatterns

Here is a working map. The urlpatterns list ties the about/ route to the about view function.

from django.urls import path
from . import views

urlpatterns = [
    path('about/', views.about),
]

Pass the View, Don't Call It

Write views.about without parentheses. Django calls the view for you when the route matches a request.

The Empty Route

An empty string route, '', matches your site's root. It is how you point the home page at a view.

path('', views.home)

Trailing Slashes Matter

Django routes usually end with a slash, like about/. This is a strong convention, so keep it consistent across routes.

Order Decides the Match

Django reads urlpatterns top to bottom and stops at the first match. Put more specific routes above broader ones.

Importing Your Views

Bring your views into urls.py first. The import line lets you reference each view by name in path calls.

from . import views

What Happens on No Match

If no pattern matches the request, Django returns a 404 error. That is your signal to add or fix a route.

Quick Check

Think about how you reference a view inside path().

Recap: You Mapped a URL

In urls.py you import path, list routes in urlpatterns, and point each one at a view. Order and trailing slashes matter. 🔗

Sıkça Sorulan Sorular

“path() ile URL Desenleri” dersi ücretsiz mi?

Evet — “path() ile URL Desenleri” 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.

“path() ile URL Desenleri” dersinde ne öğreneceğim?

urls.py içinde bir URL'yi görünüme bağlayı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.

“path() ile URL Desenleri” 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