fgasperino
unread,Dec 11, 2009, 6:12:04 PM12/11/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
All,
I have the following setup:
--models.py --
from django.db import models
from django.contrib.auth.models import User as DjangoUser
class Business (models.Model):
...
class Group (models.Model):
business = models.ForeignKey(Business)
...
class User (DjangoUser):
group = models.ForeignKey(Group)
...
--- proxies.py --
from myapp.models import Business as BusinessModel, Group as
GroupModel, User as UserModel
class Business (BusinessModel):
class Meta:
proxy = True
class Group (GroupModel):
class Meta:
proxy = True
class User (UserModel):
class Meta:
proxy = True
-- admin.py --
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin
from myapp.proxies import Business, Group, User
class BusinessAdmin (admin.ModelAdmin):
...
class GroupAdmin (admin.ModelAdmin):
...
class UserAdmin (DjangoUserAdmin):
...
admin.site.register(Business, BusinessAdmin)
admin.site.register(Group, GroupAdmin)
admin.site.register(User, UserAdmin)
As you can see, I'm trying to extend on the
django.contrib.auth.models.User. This modeling works well under the
shell, where a custom user instance would be in both the built-in User
table as well as the app-specific table.
However, the admin interface has issues. Added an instance of
myapp.models.User (via myapp.proxies.User) causes an entry in the
parent table, mapped to django.contirb.auth.models.User. It does not
create a db entry for myapp.models.User.
Any suggestions on how to solve this?
TIA,
Franco