﻿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
7932	Make it easier to use a subclass of auth.User in the admin site.	ElliottM	Brian Rosner	"I want to be able to create a subclass of the auth.User model, and entirely theplace it's use with my subclass throughout my site, including the Admin site. For the most part, this works.

There are two places it doesn't, however, and this ticket aims to fix those two places. The first is easily fixable.

In the UserAdmin's overridden ""add_view"" method, where it creates a new User. On lines 34 and 45, the UserCreationForm is hard-coded in as the form for the page. UserCreationForm is a Modelform with the model set to User. This means that if you create a subclass of User, and use a subclass of UserAdmin to manage it, your creation form will still create Users, rather than SubclassedUsers. On lines 58 and 60, the same function hard-codes references to the User model for help_text purposes and such in the context  sent to the template. 

The fix is to set a ""creation_form"" attribute in the UserAdmin declaration, and set the UserCreationform there, and change the references to UserCreationForm over to self.creation_form. Subclasses of UserAdmin are free to set the creation_form value to their own form rather than having to override the entire add_view function (as well as import everything it requires). Since ""self.model"" is already a value inherited from ModelAdmin, just use that instead of the reference to ""User"" in the context set-up. The patch I included does both of these.

The other problem is harder to fix, and I don't have a patch for it. Once on the change form for a particular SubclassedUser, the link to the ""change password form"" provided the the password field's help_text simply does not work. When you click on it, nothing happens. I'm, pretty sure this is because of the way admin.site.root handles URLS:
{{{
154 	            match = USER_CHANGE_PASSWORD_URL_RE.match(url)
155 	            if match:
156 	                return self.user_change_password(request, match.group(1))
}}}
Up above, USER_CHANGE_PASSWORD_URL_RE is defined as a regex that hard-codes in ""user"" to the url. This means that the password change URL of the SubclassedUser never matches this regex and the view never gets called.

Fixing both of these will go a very long way towards making a seamless subclass of User possible."		closed	contrib.admin	dev		fixed	subclass user admin model inheritance		Accepted	1	1	1	1	0	0
