Skip to content

AttributeError: 'NoneType' when trying to access the admin panel view list #185

@omargawdat

Description

@omargawdat

I am getting this error when trying to access the view list in the admin panel: AttributeError, as no selected provider is selected when I try to access the providers list!!
'NoneType' object has no attribute 'company'
image

rules:

import rules

@rules.predicate
def is_company_agent(user, provider):
    return provider.company == user


# Permissions setup for Provider model
rules.add_perm('users.change_provider', is_company_agent)
rules.add_perm('users.delete_provider', is_company_agent)
rules.add_perm('users.view_provider', is_company_agent)

admin code:

@admin.register(Provider)
class ProviderAdmin(ObjectPermissionsModelAdmin):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions