mirror of
https://github.com/django/django.git
synced 2025-07-23 05:05:17 +00:00
Fixed #21391 -- Allow model signals to lazily reference their senders.
This commit is contained in:
parent
03bc0a8ac5
commit
eb38257e51
7 changed files with 197 additions and 15 deletions
|
@ -413,6 +413,19 @@ different User model.
|
|||
class Article(models.Model):
|
||||
author = models.ForeignKey(settings.AUTH_USER_MODEL)
|
||||
|
||||
.. versionadded:: 1.7
|
||||
|
||||
When connecting to signals sent by the User model, you should specify the
|
||||
custom model using the :setting:`AUTH_USER_MODEL` setting. For example::
|
||||
|
||||
from django.conf import settings
|
||||
from django.db.models.signals import post_save
|
||||
|
||||
def post_save_receiver(signal, sender, instance, **kwargs):
|
||||
pass
|
||||
|
||||
post_save.connect(post_save_receiver, sender=settings.AUTH_USER_MODEL)
|
||||
|
||||
Specifying a custom User model
|
||||
------------------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue