bennylope / django-organizations

:couple: Multi-user accounts for Django projects
http://django-organizations.readthedocs.org/
BSD 2-Clause "Simplified" License
1.3k stars 212 forks source link

Error: BaseOrganizationAdmin requires 'slug' and BaseOrganizationUserAdmin requires 'is_admin' method or attribute #222

Open moojen opened 3 years ago

moojen commented 3 years ago

Dear all,

Your thoughts on the following is highly appreciated. I get the following error message (client = organization):

<class 'clients.admin.ClientAdmin'>: (admin.E027) The value of 'prepopulated_fields' refers to 'slug', which is not an attribute of 'clients.Client'.
<class 'clients.admin.ClientUserAdmin'>: (admin.E108) The value of 'list_display[2]' refers to 'is_admin', which is not a callable, an attribute of 'ClientUserAdmin', or an attribute or method on 'clients.ClientUser'. 

This, after adding the following code to admin.py:

@admin.register(Client)
class ClientAdmin(TenantAdminMixin, BaseOrganizationAdmin):
    list_display = ('name',)

@admin.register(ClientUser)
class ClientUserAdmin(BaseOrganizationUserAdmin):
    pass

I have the following models.py:

class Client(TenantMixin, OrganizationBase):
    created_on = models.DateField(auto_now_add=True)
    auto_create_schema = True

    def __str__(self):
        return self.name

class ClientOwner(OrganizationOwnerBase):
    pass

class ClientUser(OrganizationUserBase):
    pass

class ClientUserInvitation(OrganizationInvitationBase):
    pass

I'm a bit puzzled, since I've read the following on readthedocs (cookbook section):

The base models (provided in organizations.base) instead provide only the bare minimum fields required to implement and manage organizations: if you want a slug field or timestamps on your models, you’ll need to add those in. However you can do so however you want. And if you don’t want any of those fields, you don’t have to take them.

I can of course remove the code in admin.py, but I thought first I would call in your help ;-) Any feedback is much appreciated! Best, Erwin

Using Django 3.2.7 and Python 3.9.x