ลงทะเบียนแอปใน INSTALLED_APPS
ทำให้ Django รู้จักแอปใหม่ของคุณ
ลงทะเบียนแอปใน INSTALLED_APPS เป็นบทเรียน Django Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Django Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Django Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Django Must Be Told
Creating an app folder is not enough. Django only activates an app once you add it to the INSTALLED_APPS list in settings.
Find the List
Open settings.py and look near the top for INSTALLED_APPS. It is a plain Python list of strings, one per active app.
INSTALLED_APPS = [
"django.contrib.admin",
]Built-in Apps Are Already There
You will see entries like django.contrib.auth and admin. These ship with Django and power features you get for free.
Add Your App
To switch on your app, add its name as a string to the list. The simple form is just the app's folder name.
INSTALLED_APPS = [
"django.contrib.admin",
"blog",
]The Cleaner AppConfig Path
The recommended form points to the config class in apps.py. Using the full AppConfig path is the modern Django convention.
INSTALLED_APPS = [
"blog.apps.BlogConfig",
]Why Registration Matters
Once registered, Django can find your models, templates, and admin entries. Skip this step and your features simply will not load.
Unlocks Migrations
Migrations only run for apps in the list. Without registration, makemigrations ignores your models and no tables get created.
Order Can Matter
Django reads INSTALLED_APPS top to bottom. Order rarely matters, but it can affect template and static file lookups when names clash.
Mind the Commas
It is a Python list, so every entry needs a trailing comma. A missing comma is a classic, confusing beginner error here.
Verify It Loaded
After editing, run the dev server. If Django starts without an error about your app, the registration worked correctly.
python manage.py runserverThird-Party Apps Too
Installed packages like Django REST Framework also go in this list. Registering them is what turns a pip install into working features.
Quick Check
What happens to your app's models if you forget INSTALLED_APPS?
Recap: App Switched On
You added your app to INSTALLED_APPS, ideally via its AppConfig path. That one line lets Django load your models, admin, and migrations. ✅
คำถามที่พบบ่อย
บทเรียน “ลงทะเบียนแอปใน INSTALLED_APPS” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ลงทะเบียนแอปใน INSTALLED_APPS” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Django Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Django Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ลงทะเบียนแอปใน INSTALLED_APPS”
ทำให้ Django รู้จักแอปใหม่ของคุณ คุณปฏิบัติ Django Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Django Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Django Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “ลงทะเบียนแอปใน INSTALLED_APPS” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Django Academy นี้ได้ไหม
ได้ บทเรียน Django Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- startapp และโครงสร้างโฟลเดอร์แอป
- ลงทะเบียนแอปใน INSTALLED_APPS
- สำรวจ settings.py
- manage.py: ศูนย์บัญชาการของคุณ