Alex Rivera | Logout

Django - Allow duplicate usernames

Asked 2010-01-08T15:22:39.947
11

I'm working on a project in django which calls for having separate groups of users in their own username namespace.

So for example, I might have multiple "organizations", and username should only have to be unique within that organization.

I know I can do this by using another model that contains a username/organization id, but that still leaves this useless (and required) field on the defualt django auth User that I would have to populate with something.

I've already written by own auth backend that authenticates a user against LDAP. However, as I mentioned before, I am still stuck with the problem of how to populate / ignore the username field on the default django user.

Is there a way to drop the uniqueness constraint for the username for Django auth users?

Edit
Report

1 Answer

1

I have not personally been required to find a solution to this, but one way to tackle this (from an SAAS perspective) would be to prefix the username with an organizational identifier (presuming unique organizations). For example: subdomain.yoursite.com would equate to a user with the username: subdomain_username. You would just have to code some business logic on login to a subdomain to tack that onto the username.

answered 2010-01-08T16:40:02.560

Your Answer