L
L
LVitA2018-10-09 12:45:15
Django
LVitA, 2018-10-09 12:45:15

Why don't user permissions change (Django)?

Good day!
I can't understand why when changing user rights, he still has rights that were not granted to him.

Screenshot from the admin
5bbc77408b078863003947.png
Model code
class Account(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField('Email', max_length=150, unique=True)
    name = models.CharField('Имя', max_length=255, blank=True, unique=True)
    is_active = models.BooleanField('Активный?', default=False)
    is_staff = models.BooleanField('Модератор?', default=False)
    is_superuser = models.BooleanField('Админ?', default=False)
    date_joined = models.DateTimeField('Дата создания', auto_now_add=True)

    USERNAME_FIELD = 'name'
    REQUIRED_FIELDS = ['email']

    objects = UserManager()

    def __str__(self):
        return self.name

    def get_full_name(self):
        return self.name

    def get_email(self):
        return self.email

    def has_perm(self, perm, obj=None):
        return True

    def has_module_perms(self, app_label):
        return True

    class Meta:
        verbose_name = 'Пользователь'
        verbose_name_plural = 'Пользователи'

admin.py
class AccountAdmin(BaseUserAdmin):
    add_form = UserAdminCreationForm
    list_display = ['name', 'email', 'is_superuser']
    list_filter = ['is_superuser', 'is_active', 'is_staff']

    fieldsets = (
        (None, {'fields': ('email', 'password')}),
        ('Информация', {'fields': ('name', )}),
        ('Разрешения', {'fields': ('is_active',
                                   'is_superuser', 'is_staff', 'groups', 'user_permissions')}),
    )

    add_fieldsets = (
        (None, {
            'classes': ('wide',),
            'fields': ('name', 'email', 'password1', 'password2', 'groups', 'user_permissions')}
         ),
    )

    search_fields = ['email']
    ordering = ['email']
    filter_horizontal = ('groups', 'user_permissions')


admin.site.register(Account, AccountAdmin)


and another question, is it possible to change the name of the group in the admin panel, namely "Account" in the screenshot:
Screenshot
5bbc7874c0159366164228.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2015-06-30
@Mistin

It's better to have one big image, and then use magic to make images of any size from it
https://www.djangopackages.com/grids/g/thumbnails/
sorl-thumbnail.readthedocs.org/en/latest/examples... .

A
Andrey K, 2015-06-30
@mututunus

Use https://github.com/mariocesar/sorl-thumbnail

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question