Skip to content

Dynamically set admin url name to be redirected to on action execution #49

@An4ik

Description

@An4ik

I have a few admin pages i.g.

/admin/ ---> for company users (our company)
/c-admin --> for customer users
/super-admin/ ---> for me (everything is allowwed)

so I would like to add inline actions to /c-admin/ but after pressing it it will redirect to admin defaul one cause:
https://github.com/escaped/django-inline-actions/blob/master/inline_actions/admin.py#L205

if parent_obj is None:  # InlineActionsMixin.MODEL_ADMIN:
    # redirect to `changelist`
    url = reverse(
        'admin:{}_{}_changelist'.format(
            obj._meta.app_label,
            obj._meta.model_name,
        ),
    )
else:
    # redirect to `changeform`
    url = reverse(
        'admin:{}_{}_change'.format(
            parent_obj._meta.app_label,
            parent_obj._meta.model_name,
        ),
        args=(parent_obj.pk,),
    )

I the way I would like to handle it:

Read the admin url name from admin class. if it's not found use default admin but it can be also overridden in settings

For example:

def get_admin_url_base_name() --> str:
   """
   Return admin sitem base name can be extracted from self.admin_site
   """
   
 

  url = reverse(
        'admin:{}_{}_change'.format(
            parent_obj._meta.app_label,
            parent_obj._meta.model_name,
        ),
        args=(parent_obj.pk,),
    )

If you ok and agree with this issue I can handle it

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