Search code examples
djangopostgresqldatabase-schemadjango-registration

Django registration fails with schema search path in Postgres


I need to share user credentials across multiple django apps. Each app is completely different and serves different purposes, but I want a user to only have to register once in order to use any of the apps.

I have managed to set this up by defining multiple schemas in my Postgres db. As far as I could find on the web schemas are not supported in Django explicitly but I did get it to work (mostly) by just defining a different search path for each app (each app uses its own username to connect to Postgres).

I have the following schemas (as an example):

- auth
- app1    
- app2
- app3
- common

So an app's user's search path might look something like this:

app1, common, auth

Everything seems to work fine, except the registration functionality provided by django-registration. When I try to register a new user it creates a new row in the auth_user table as well as the registration_registrationprofile tables (both reside in the auth schema). The activation email is also sent, but when I click on the activation link I get a message that "Account activation failed". No other info.

Has anyone else seen this and maybe have a solution to get activation working in a setup like this?


Solution

  • Ah, the reason why the activation failed had nothing to do with the registration module. My template for the activation email contained an activation url for the production site and I was testing on a staging site. (blush)