OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to create users and groups migrations in Django?

  • Thread starter Thread starter kramer65
  • Start date Start date
K

kramer65

Guest
So I've got an API built in Django with Django Rest Framework and I now want to add a role based access control to it. For this I found the django-rest-framework-roles extension. I've got it installed, but I'm not really familiar with the usual authentication system in Django. It says I need to define the groups in the settings as

Code:
ROLE_GROUPS = [group.name.lower() for group in Group.objects.all()]

So I need the Group model and of course also the User model. As far as I understand, these are standard models. However, I don't have any tables in my DB for them. So I need a migration for it, but I'm unsure how I can do that.

I guess it should be really easy, but even on the relevant pages in the documentation I don't see any mention on how to add these models to my Django installation.

What can I try next?
<p>So I've got an API built in Django with Django Rest Framework and I now want to add a role based access control to it. For this I found the <a href="https://github.com/computer-lab/django-rest-framework-roles" rel="nofollow noreferrer">django-rest-framework-roles extension</a>. I've got it installed, but I'm not really familiar with the usual authentication system in Django. It says I need to define the groups in the settings as</p>
<pre><code>ROLE_GROUPS = [group.name.lower() for group in Group.objects.all()]
</code></pre>
<p>So I need the <code>Group</code> model and of course also the <code>User</code> model. As far as I understand, these are standard models. However, I don't have any tables in my DB for them. So I need a migration for it, but I'm unsure how I can do that.</p>
<p>I guess it should be really easy, but even on <a href="https://docs.djangoproject.com/en/3.1/topics/auth/default/" rel="nofollow noreferrer">the relevant pages in the documentation</a> I don't see any mention on how to add these models to my Django installation.</p>
<p>What can I try next?</p>
 

Latest posts

A
Replies
0
Views
1
Anthonin Chaboteaux
A
Top