Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4548720
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:15:37+00:00 2026-05-21T16:15:37+00:00

I have a usergroup called baseusers with a set of permissions I have added

  • 0

I have a usergroup called baseusers with a set of permissions I have added via admin. If baseusers doesn’t exist I want to create it and set the same permissions it has now. I can create the group but how do I find out the permissions from shell and then add them in my code? For example two of the permissions are named can_fm_list and can_fm_add. Application is called fileman. But do I need to use id:s instead? Here is the code I would like the permissions to be set.

userprofile/views.py

from fileman.models import Setting (Has the permissions)
from fileman.models import Newuserpath
from django.contrib.auth.models import Group

def register(request):

...

            if Group.objects.count() > 0:
            newuser.groups.add(1)
            else:
            newgroup = Group(name='baseusers')
            newgroup.save()
            newuser.groups.add(1)

fileman/models.py

class Setting(models.Model):
    owner = AutoForeignKey(User, unique=True, related_name='fileman_Setting')
    root = models.CharField(max_length=250, null=True)
    home = models.CharField(max_length=250, null=True)
    buffer = models.TextField(blank=True)
    class Meta:
        permissions = (
            ("can_fm_list", _("Can look files list")),
            ("can_fm_add", _("Can upload files")),
            ("can_fm_rename", _("Can rename files")),
            ("can_fm_del", _("Can move files to basket")),
            ("can_fm_destruct", _("Can delete files")),
        )
    def __unicode__(self):
        return unicode(self.owner)
    def __init__(self, *args, **kwargs):
        super(Setting, self).__init__(*args, **kwargs)
        if not self.root:
            self.root = None
            self.home = None
    def writeBuffer(self, data):
        self.buffer = data
        self.save()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:15:38+00:00Added an answer on May 21, 2026 at 4:15 pm

    Take a look at this blog post: Django: Using The Permission System

    Adapted to your example:

    can_fm_list = Permission.objects.get(name='can_fm_list')
    newgroup.permissions.add(can_fm_list)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 models, usergroups and usergrouppermissions. my usergrouppermissions has a field called user_group_id
I have an object that has properties of another object and one called DataValue
I have four class; UserGroup, UserAccount, Role, UserGroupRoleRelation and my db is IBM DB2
Assume that I have three class; UserAccount, UserGroup and Role. UserGroup and Role are
Suppose I have two entities: User and UserGroup . They have a one-to-many relationship
I have a query like below... SELECT contents.id, contents.title, contents.createdBy, (SELECT userGroup FROM suser_profile
I have used column-based relations a lot in my projects like: CREATE TABLE `user`
I have a class called user that contains a list of groups that are
In the database I have 3 tables, User, Group and a lookup table UserGroup
Assuming I have classes User and UserGroup. There is an optional 1-many group to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.