﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19631	get_user_model() can't be used as User post_save signal sender	Filip Wasilewski <en@…>	nobody	"Or in other words there is no safe way to register a signal handler for user model (which may be customized) in a reusable app.

As the [https://docs.djangoproject.com/en/dev/topics/auth/customizing/#custom-users-and-signals documentation] says it is only possible to register a concrete user model class as a signal sender (in particular for the {{{post_save}}} signal).

''Another limitation of custom User models is that you can't use {{{django.contrib.auth.get_user_model()}}} as the sender or target of a signal handler. Instead, you must register the handler with the resulting User model. See Signals for more information on registering an sending signals.''

On the other hand the docs recommends another popular strategy of [https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model extending user model] by one-to-one profile models that can be created/updated via {{{post_save}}} signal when the related user model is saved.

This is all fine and I think I understand the limitations of {{{get_user_model()}}}, but the things begin to break when reusable apps that make use of one-to-one user profiles are put into the context.

IMHO reusable apps should be able to work with any standard/custom model and be able to register signal handlers (in {{{models.py}}} or any other safe place) on the resulting user model without having to hardcode imports of concrete model classes.

If it is is too hard to provide a decent solution for the problem I think it would be worth to document the preferred workaround/migration approach or even indicate this case as backward-incompatible change (note that Django 1.4 is going to have {{{get_user_model()}}} backported for compatibility reasons) for reusable apps that rely on the User's {{{post_save}}} signal and which try to be compatible with Django 1.4 and 1.5."	Bug	closed	Database layer (models, ORM)	1.5-beta-1	Normal	invalid	custom user model signal		Unreviewed	0	0	0	0	0	0
