0

In a typical database, admin can assign users and can create tables which can be accessed by only a particular set of users or groups. One can also create queries that can be made by certain users in a database like MySQL.

Does Django provide any such functionality or is is it only the Django ADMIN Interface that does this?

I am aware that the admin can create users and provide them with permissions for working with app models.

0

2 Answers 2

1

Django by itself doesn't provide access to the database-level users / groups / permissions, because it doesn't make much sense for a typical web application where all connections will be made with the same database user (the one defined in settings.DATABASES). Note that it's not a shortcoming be really the standard for web applications.

What Django provides is application-level users / groups / permissions (cf https://docs.djangoproject.com/en/1.8/topics/auth/). You have access to this application-level layer thru the admin but also - of course - programmatically thru the django.contrib.auth package.

Sign up to request clarification or add additional context in comments.

2 Comments

Hey @brunodesthuilliers, Thanks for the info. My follow up question is about how django translates the user permissions in the admin interface on the models to the database level. I know that it uses Object Relational Mapping for converting models to tables in a database.
@susheel Django is OSS so you can check by yourself how django.contrib.auth is implemented. Quick answer: it's all based on models for users, groups, permissions and the relationships between them.
-1

Yes, you can do that.

Django defined these models in module django.contrib.auth.models

You can import all models from there like Group, Permission and all.

from django.contrib.auth.models import *

If you want to list all django auth models you can see them in mysql/or other database too by prefix auth_* e.g, in mysql

show tables like "%auth%";

Over these models you can use django ORM.

1 Comment

@vaibav-kumar I think the OP was asking about database level users and permissions, not application level.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.