Create admin/superuser for each tenant/schema, while using Django-Tenant-Schema

1,205 views
Skip to first unread message

Sayantan Ganguly

unread,
Jun 16, 2016, 11:06:39 AM6/16/16
to Django users
I am using Django-Tenant-Schemas for my multi tenant app.

Now, I have come to face a huge problem.

I need to use @login-required for views. But how to have an admin (the creator & owner of the schema) to only create/register user. If a "register yourself" page is available to all, then anyone can register.

If I can have an admin for each tenant, then I can easily use @required-permission decorator for the "register" view.

Hence, my question is how to create admin/super user for each tenant.


I cannot create the admin from the "create database"/"register your firm" (which is getting dynamically created from the register page, linked to the landing page) view as it is in the public schema.

monoBOT

unread,
Jun 17, 2016, 10:41:24 AM6/17/16
to django...@googlegroups.com
You can use one of the utils in that library

from tenant_schemas.utils import schema_context
from django.contrib.auth.models import User

with schema_context('yourschemaname'):
     ...

Or you can manually run the management command form the shell

python manage.py createsuperuser



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/962cf79a-f1ad-4709-8f07-5888429450a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
monoBOT
Visite mi sitio(Visit my site): monobotsoft.es/blog/
Reply all
Reply to author
Forward
0 new messages