Re: Django 1.5: AUTH_USER_MODEL and GeoManager

344 views
Skip to first unread message

Luke Plant

unread,
Oct 11, 2012, 11:49:22 AM10/11/12
to django-d...@googlegroups.com
On 11/10/12 08:51, Max wrote:
> Hi there,
> this is my first post here; hope I'm posting to the right group.
> I'm currently working on getting to run an 1.4-application (using a
> profile model) on 1.5dev, using the the new (eagerly awaited by me)
> custom user model.
> I used django.contrib.gis.db.GeoManager with my former profile-Model and
> so I wanted to use it with my new custom user model, too.
> The following exception was thrown:
>
> " 'GeoManager' object has no attribute 'get_by_natural_key' "
>
> Hacking contrib/gis/db/models/manager.py and making GeoManager subclass 'django.contrib.auth.models.UserManager'
>
> instead of 'Manager' solved it for the moment.
>
> Maybe this is something that hasn't been thought of yet.
>
> I felt like I should post this.

If you could create a ticket, that will ensure this is not forgotten. It
sounds like it should be a release blocker.

Luke


--
"Because Your lovingkindness is better than life,
My lips shall praise You." (Ps 63:3)

Luke Plant || http://lukeplant.me.uk/

ptone

unread,
Oct 11, 2012, 7:51:04 PM10/11/12
to django-d...@googlegroups.com


On Thursday, October 11, 2012 12:51:07 AM UTC-7, Max wrote:
Hi there,
this is my first post here; hope I'm posting to the right group.
I'm currently working on getting to run an 1.4-application (using a profile model) on 1.5dev, using the the new (eagerly awaited by me) 
custom user model.
I used django.contrib.gis.db.GeoManager with my former profile-Model and so I wanted to use it with my new custom user model, too.
The following exception was thrown:
" 'GeoManager' object has no attribute 'get_by_natural_key' "
Hacking contrib/gis/db/models/manager.py and making GeoManager subclass 'django.contrib.auth.models.UserManager' 
instead of 'Manager' solved it for the moment.
Maybe this is something that hasn't been thought of yet.
I felt like I should post this.

Custom user objects require a custom manager that inherits from at least django.contrib.auth.models.BaseUserManager, which defines the get_by_natural_key method

Because the GeoManager defines a completely non-conflicting set of methods - you should be able to define your manager as:

class MyCustomGeoUserManager(BaseUserManager, GeoManager):

and then defining create_user and create_superuser per the docs

-Preston 
Reply all
Reply to author
Forward
0 new messages