djadmin icon indicating copy to clipboard operation
djadmin copied to clipboard

Not supporting in Django 2

Open ManojDatt opened this issue 5 years ago • 5 comments

It is not supporting in Django 2,I have fixed this issue on my local. If possible add me as a contributor so that i can make those changes, Or You need to fix few changes i am attaching a file for this fixes please update.

ManojDatt avatar Sep 27 '19 09:09 ManojDatt

I have fixed and updated code over django2 branch.

ManojDatt avatar Sep 30 '19 12:09 ManojDatt

Can you generate PULL request to master so I'll merge it

sainipray avatar Oct 01 '19 10:10 sainipray

I want to use it and i fixed issues in django latest. But I am not getting permission options while adding user or group from admin. Can you help? Screenshot (35)

Coderknight439 avatar Oct 30 '19 19:10 Coderknight439

I want to use it and i fixed issues in django latest. But I am not getting permission options while adding user or group from admin. Can you help? Screenshot (35)

Not sure if this helps but there some updates regarding permissions in latest Django. Please check. https://docs.djangoproject.com/en/3.0/releases/2.1/#considerations-for-the-new-model-view-permission

mjrulesamrat avatar Dec 18 '19 08:12 mjrulesamrat

Install latest from :

pip install git+https://github.com/sainipray/djadmin.git@django2

And add this in your admin.

from django.contrib.auth.admin import GroupAdmin
from django.contrib.auth.models import Group
class CustomGroupAdmin(GroupAdmin):
    def formfield_for_manytomany(self, db_field, request=None, **kwargs):
        if db_field.name == 'permissions':
            qs = kwargs.get('queryset', db_field.remote_field.model.objects)
            qs = qs.exclude(codename__in=(
                'add_permission',
                'change_permission',
                'delete_permission',

                'add_contenttype',
                'change_contenttype',
                'delete_contenttype',

                'add_session',
                'delete_session',
                'change_session',

                'add_logentry',
                'change_logentry',
                'delete_logentry',
            ))
            
            kwargs['queryset'] = qs.select_related('content_type')
        return super(GroupAdmin, self).formfield_for_manytomany(
            db_field, request=request, **kwargs)
admin.site.register(Group, CustomGroupAdmin)

This will allow you to add permission for groups.

ManojDatt avatar Dec 19 '19 18:12 ManojDatt