kmmbvnr / django-guardian-ng

Per object permissions for Django
https://django-guardian.readthedocs.io/
Other
1 stars 0 forks source link

Polymorphic abstract class fails to generate permissions #24

Closed kmmbvnr closed 5 months ago

kmmbvnr commented 5 months ago

Original issue: https://github.com/django-guardian/django-guardian/issues/778

kmmbvnr commented 5 months ago

Can't reproduce

image

from django.db import models
from polymorphic.models import PolymorphicModel

class Project(PolymorphicModel):
    topic = models.CharField(max_length=30)

class ArtProject(Project):
    artist = models.CharField(max_length=30)

class ResearchProject(Project):
    supervisor = models.CharField(max_length=30)

from django.contrib import admin
from guardian.admin import GuardedModelAdmin
from . import models

@admin.register(models.Project)
class ProjectAdmin(GuardedModelAdmin):
     pass

@admin.register(models.ArtProject)
class ArtProjectAdmin(GuardedModelAdmin):
    pass

@admin.register(models.ResearchProject)
class ResearchProjectAdmin(GuardedModelAdmin):
    pass
kmmbvnr commented 5 months ago

Closed as https://github.com/django-guardian/django-guardian/issues/778#issuecomment-2097302146

Probably the use was created tables before, and only then make the class abstract. The django-polymorphic itself does not allow to have base abstract classes

kmmbvnr commented 5 months ago

Found a way to reproduce

kmmbvnr commented 5 months ago

Find that permissions is not create for the abstract classes by Django, but in case if they created manually, everything works fine https://github.com/django-guardian/django-guardian/issues/778#issuecomment-2098279253