
Django Signals
Built-in signals, pre_save, post_save, pre_delete, custom signals, receivers, signal best practices
1What is a signal in Django?
What is a signal in Django?
คำตอบ
A signal is a mechanism allowing certain parts of the application to be notified when specific actions occur elsewhere in the framework. Signals enable decoupling between the event sender and the receivers that react to that event. Django provides several built-in signals like pre_save, post_save, pre_delete and post_delete for model operations.
2Which signal is emitted just before an object is saved to the database?
Which signal is emitted just before an object is saved to the database?
คำตอบ
The pre_save signal is emitted before a model's save() method is executed. It allows making modifications to the instance before it is saved, such as calculating derived values or normalizing data. This signal is useful because it is called whether the object is being created or updated.
3Which decorator should be used to connect a receiver function to a Django signal?
Which decorator should be used to connect a receiver function to a Django signal?
คำตอบ
The @receiver decorator from django.dispatch allows connecting a function to a signal declaratively. It takes the signal to listen to as a parameter and optionally the sender to filter emitters. This approach is more readable than the connect() method and makes code maintenance easier.
Which argument of the post_save signal allows distinguishing a creation from an update?
Where is it recommended to place signal receiver code in a Django application?
+15 คำถามสัมภาษณ์
หัวข้อสัมภาษณ์ Django อื่นๆ
Python Basics
Python OOP
Django Fundamentals
Django Models - Basics
Django Views
Django Templates
Django Forms
Advanced QuerySets
Django Authentication
Django Middleware
Django Admin
Django REST Framework
File Upload
Django Caching
Django Sessions
Django Email
Django Testing
Django Security
Django Deployment
Advanced Django ORM
Django Performance
Django & Celery
Django Channels
Django & GraphQL
Django & Docker
Django in Microservices Ecosystem
Custom Django Commands
Django Internationalization
Django Design Patterns
Django Async & ASGI
Settings & Production Configuration
Observability & Monitoring
เชี่ยวชาญ Django สำหรับการสัมภาษณ์ครั้งถัดไป
เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์
เริ่มใช้ฟรี