User Modeli ve authenticate()
Yerleşik kullanıcıyla kimlik bilgilerini doğrulayın.
User Modeli ve authenticate(), CoddyKit'te ücretsiz bir Django Academy dersidir. Bu, 4 dersinin 1. 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.
You Already Have Users
Django ships a full User model out of the box, so you never write account tables by hand. It stores usernames, hashed passwords, and more. 👤
Where the User Lives
The model sits in django.contrib.auth, an app that is enabled in fresh projects. Import it and the whole auth toolkit comes along.
from django.contrib.auth.models import UserKey User Fields
Each user has a username, plus email, first_name, and last_name. These are the everyday fields you read and display in your app.
Passwords Are Never Plain
Django stores a salted hash of every password, never the raw text. Even you, the developer, cannot read a user's actual password. 🔒
Create a User Safely
Use create_user so the password gets hashed for you. Setting the password by hand would store it in the clear.
User.objects.create_user(username="ada", password="secret123")Meet authenticate()
The authenticate() function checks a username and password against the database for you. It is the heart of every login flow.
from django.contrib.auth import authenticateHow authenticate() Works
Pass it the credentials and it returns the matching user object when they are correct. No hashing or lookups for you to write.
user = authenticate(username="ada", password="secret123")When Credentials Fail
If the username or password is wrong, authenticate() returns None. Always check for that before treating the user as logged in.
if user is None:
print("Invalid credentials")Active Users Only
The is_active flag lets you disable accounts. By default authenticate() refuses to return inactive users, blocking banned logins.
Staff and Superusers
Two extra flags matter: is_staff grants admin-site access, and is_superuser grants every permission. Most users have neither.
Authenticate Is Not Login
Remember: authenticate() only verifies identity. It does not start a session, so the user is not yet logged in after this call.
Quick Check
What does authenticate() return when the password is wrong?
Recap: Users and Identity
You met Django's built-in User model and used authenticate() to verify credentials. Passwords stay hashed, and a failed check gives None. ✅
Sıkça Sorulan Sorular
“User Modeli ve authenticate()” dersi ücretsiz mi?
Evet — “User Modeli ve authenticate()” 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.
“User Modeli ve authenticate()” dersinde ne öğreneceğim?
Yerleşik kullanıcıyla kimlik bilgilerini doğrulayı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 1. dersidir.
“User Modeli ve authenticate()” 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
- User Modeli ve authenticate()
- login, logout ve Kimlik Doğrulama Görünümleri
- UserCreationForm ile Kayıt
- login_required ve Görünümleri Koruma