<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Extending the Django User model with inheritance</title>
	<atom:link href="http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/feed/" rel="self" type="application/rss+xml" />
	<link>http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/</link>
	<description>Code and comments on web development, Django, Python and things (un)related.</description>
	<lastBuildDate>Thu, 04 Mar 2010 16:35:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: bufh</title>
		<link>http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/comment-page-2/#comment-766</link>
		<dc:creator>bufh</dc:creator>
		<pubDate>Wed, 20 Jan 2010 16:12:56 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/#comment-766</guid>
		<description>Hi,

thank you for this article.

Unfortunately i&#039;m having an issue; i&#039;m able to create a CustomUser through the admin interface (like described in comment #8).
But the CustomUsers will appears in admin/auth/user/ (without the custom fields) and nothing will appear in admin/myapp/customuser/.

Is there a clean way to fully add/list/edit extended users through the admin interface or must i make my own admin interface?</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>thank you for this article.</p>
<p>Unfortunately i&#8217;m having an issue; i&#8217;m able to create a CustomUser through the admin interface (like described in comment #8).<br />
But the CustomUsers will appears in admin/auth/user/ (without the custom fields) and nothing will appear in admin/myapp/customuser/.</p>
<p>Is there a clean way to fully add/list/edit extended users through the admin interface or must i make my own admin interface?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karol Joc</title>
		<link>http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/comment-page-2/#comment-752</link>
		<dc:creator>Karol Joc</dc:creator>
		<pubDate>Mon, 21 Dec 2009 11:42:54 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/#comment-752</guid>
		<description>I have found one problem with apply this new extension to the User class. Maybe there is a simple solution to it..

When I create a foreign key to the new CustomUser class and specify &quot;to_field = &#039;username&#039;&quot; it works fine with validation and saving but the moment you try and do a order_by on the new model which references a field in the User model it fails with customuser__username  field not found. 

Example:

&lt;pre&gt;class CustomUser(User):
    ......

class X(models.Model):
    added_by = models.ForeignKey(CustomUser, to_field = &#039;username&#039;)

X.objects.all().order_by(&#039;added_by__last_name)
&lt;/pre&gt;
I use auto complete fields in my forms that use the username as a value so if I don&#039;t specify to_field in my model the validation will fail as it&#039;s expecting the CustomUser.id.

Maybe there is a way to tell the ModelForm to validate using the username?</description>
		<content:encoded><![CDATA[<p>I have found one problem with apply this new extension to the User class. Maybe there is a simple solution to it..</p>
<p>When I create a foreign key to the new CustomUser class and specify &#8220;to_field = &#8216;username&#8217;&#8221; it works fine with validation and saving but the moment you try and do a order_by on the new model which references a field in the User model it fails with customuser__username  field not found. </p>
<p>Example:</p>
<pre>class CustomUser(User):
    ......

class X(models.Model):
    added_by = models.ForeignKey(CustomUser, to_field = 'username')

X.objects.all().order_by('added_by__last_name)
</pre>
<p>I use auto complete fields in my forms that use the username as a value so if I don&#8217;t specify to_field in my model the validation will fail as it&#8217;s expecting the CustomUser.id.</p>
<p>Maybe there is a way to tell the ModelForm to validate using the username?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Django: Model Inheritance or Related Tables wrt AMO at Spindrop</title>
		<link>http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/comment-page-2/#comment-747</link>
		<dc:creator>Django: Model Inheritance or Related Tables wrt AMO at Spindrop</dc:creator>
		<pubDate>Tue, 15 Dec 2009 20:12:30 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/#comment-747</guid>
		<description>[...] other things we wanted, so it made sense for us to use it. The next question is whether we try the inheritance approach or do we treat our legacy users table as a sort of User Profile and utilize the User module using [...]</description>
		<content:encoded><![CDATA[<p>[...] other things we wanted, so it made sense for us to use it. The next question is whether we try the inheritance approach or do we treat our legacy users table as a sort of User Profile and utilize the User module using [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bufke</title>
		<link>http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/comment-page-2/#comment-742</link>
		<dc:creator>Bufke</dc:creator>
		<pubDate>Sat, 28 Nov 2009 00:37:54 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/#comment-742</guid>
		<description>I found a hack to fix the createsuperuser and other problems when one creates a user instead of the custom user.  Just use a sql trigger(I use mysql).  Something like

delimiter //
create trigger trigger_custom_user
after insert on auth_user
for each row
begin
insert into myapp_customuser (user_ptr_id) values(NEW.id);
//

It&#039;s at the sql level and therefore not ideal, but it works.</description>
		<content:encoded><![CDATA[<p>I found a hack to fix the createsuperuser and other problems when one creates a user instead of the custom user.  Just use a sql trigger(I use mysql).  Something like</p>
<p>delimiter //<br />
create trigger trigger_custom_user<br />
after insert on auth_user<br />
for each row<br />
begin<br />
insert into myapp_customuser (user_ptr_id) values(NEW.id);<br />
//</p>
<p>It&#8217;s at the sql level and therefore not ideal, but it works.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MarioGonzalez</title>
		<link>http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/comment-page-2/#comment-726</link>
		<dc:creator>MarioGonzalez</dc:creator>
		<pubDate>Thu, 01 Oct 2009 22:43:16 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/#comment-726</guid>
		<description>$ python manage.py createsuperuser does not &#039;obey&#039; this configuration it stills create the user in User model. Is that a support lack or is there something I&#039;m doing wrong?</description>
		<content:encoded><![CDATA[<p>$ python manage.py createsuperuser does not &#8216;obey&#8217; this configuration it stills create the user in User model. Is that a support lack or is there something I&#8217;m doing wrong?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/comment-page-2/#comment-713</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Wed, 09 Sep 2009 20:30:45 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/#comment-713</guid>
		<description>Hacked this a bit to allow the backend to assign a user subclass based on the user&#039;s group attribute.

http://steps.ucdavis.edu/People/jbremson/extending-the-user-model-in-django</description>
		<content:encoded><![CDATA[<p>Hacked this a bit to allow the backend to assign a user subclass based on the user&#8217;s group attribute.</p>
<p><a href="http://steps.ucdavis.edu/People/jbremson/extending-the-user-model-in-django" rel="nofollow">http://steps.ucdavis.edu/People/jbremson/extending-the-user-model-in-django</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/comment-page-2/#comment-712</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Wed, 09 Sep 2009 06:44:59 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/#comment-712</guid>
		<description>I just wanted to say thank you. This is an elegant solution to a common problem.</description>
		<content:encoded><![CDATA[<p>I just wanted to say thank you. This is an elegant solution to a common problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Masarliev</title>
		<link>http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/comment-page-1/#comment-707</link>
		<dc:creator>Masarliev</dc:creator>
		<pubDate>Tue, 11 Aug 2009 17:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/#comment-707</guid>
		<description>Hi all. 
I tried to create a form from CustomUser model. Everything  is fine except that fields from customUser model can&#039;t be saved. 
Sorry for my bad English</description>
		<content:encoded><![CDATA[<p>Hi all.<br />
I tried to create a form from CustomUser model. Everything  is fine except that fields from customUser model can&#8217;t be saved.<br />
Sorry for my bad English</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/comment-page-1/#comment-704</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Sun, 26 Jul 2009 20:28:25 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/#comment-704</guid>
		<description>@Necmettin Begiter

If the 403 CSRF error is the problem you are having I suggest you remove &lt;code&gt;django.contrib.csrf.middleware.CsrfMiddleware&lt;/code&gt; from your &lt;code&gt;MIDDLEWARE_CLASSES&lt;/code&gt; and find out what the problem really is.</description>
		<content:encoded><![CDATA[<p>@Necmettin Begiter</p>
<p>If the 403 CSRF error is the problem you are having I suggest you remove <code>django.contrib.csrf.middleware.CsrfMiddleware</code> from your <code>MIDDLEWARE_CLASSES</code> and find out what the problem really is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Necmettin Begiter</title>
		<link>http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/comment-page-1/#comment-702</link>
		<dc:creator>Necmettin Begiter</dc:creator>
		<pubDate>Sun, 26 Jul 2009 15:23:27 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/#comment-702</guid>
		<description>This idea is actually great. Thanks, and I think it would be nice to promote this method as much as possible.

Yet I failed to apply this method successfully.
First, the changes I&#039;ve made:

--- Added to settings.py bottom:
&lt;pre&gt;AUTHENTICATION_BACKENDS = (
    &#039;website.auth_backends.CustomUserModelBackend&#039;,
)

CUSTOM_USER_MODEL = &#039;profiles.CustomUser&#039;
&lt;/pre&gt;

--- Added to urls.py top:
&lt;pre&gt;from django.conf.urls.defaults import *
from django.contrib.auth.models import User
from django.contrib import admin
admin.autodiscover()
admin.site.unregister(User)
&lt;/pre&gt;

--- settings.py INSTALLED_APPS:
&lt;pre&gt;(    &#039;django.contrib.auth&#039;,
    &#039;django.contrib.contenttypes&#039;,
    &#039;django.contrib.sessions&#039;,
    &#039;django.contrib.sites&#039;,
    &#039;django.contrib.admin&#039;,
    &#039;fullhistory&#039;,
    &#039;website.courses&#039;,
    &#039;website.profiles&#039; )
&lt;/pre&gt;

--- profiles/models.py:
&lt;pre&gt;from django.db import models
from django.contrib.auth.models import User, UserManager
from fullhistory import register_model #this has nothing to do with users, it just logs every write to the database
from website.courses.models import Course #website is my Django project folder obviously

class CustomUser(User):
    cellphone = models.CharField(max_length=20)
    courses = models.ForeignKey(Course, null=True, blank=True)
    updatedat = models.DateTimeField(null=True, blank=True)

    objects = UserManager()
&lt;/pre&gt;

I&#039;ve tried with and without AUTH_PROFILE_MODULE = &#039;profiles.CustomUser&#039;, but with no luck.

Any suggestions?

Forgot to add, it gives me 403 CSRF.</description>
		<content:encoded><![CDATA[<p>This idea is actually great. Thanks, and I think it would be nice to promote this method as much as possible.</p>
<p>Yet I failed to apply this method successfully.<br />
First, the changes I&#8217;ve made:</p>
<p>&#8212; Added to settings.py bottom:</p>
<pre>AUTHENTICATION_BACKENDS = (
    'website.auth_backends.CustomUserModelBackend',
)

CUSTOM_USER_MODEL = 'profiles.CustomUser'
</pre>
<p>&#8212; Added to urls.py top:</p>
<pre>from django.conf.urls.defaults import *
from django.contrib.auth.models import User
from django.contrib import admin
admin.autodiscover()
admin.site.unregister(User)
</pre>
<p>&#8212; settings.py INSTALLED_APPS:</p>
<pre>(    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'fullhistory',
    'website.courses',
    'website.profiles' )
</pre>
<p>&#8212; profiles/models.py:</p>
<pre>from django.db import models
from django.contrib.auth.models import User, UserManager
from fullhistory import register_model #this has nothing to do with users, it just logs every write to the database
from website.courses.models import Course #website is my Django project folder obviously

class CustomUser(User):
    cellphone = models.CharField(max_length=20)
    courses = models.ForeignKey(Course, null=True, blank=True)
    updatedat = models.DateTimeField(null=True, blank=True)

    objects = UserManager()
</pre>
<p>I&#8217;ve tried with and without AUTH_PROFILE_MODULE = &#8216;profiles.CustomUser&#8217;, but with no luck.</p>
<p>Any suggestions?</p>
<p>Forgot to add, it gives me 403 CSRF.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.216 seconds -->
