django-hijack-admin icon indicating copy to clipboard operation
django-hijack-admin copied to clipboard

HijackUserAdminMixin should live in a separate file

Open andybak opened this issue 8 years ago • 2 comments

Anyone who has existing customizations will want to avoid the unregister/register code and use the mixin on it's own. However - this currently isn't possible as HijackUserAdminMixin is in the same module. I'd suggest moving it to a module called something like admin_mixins.py and importing it from there.

(That does raise the question of why the non-mixin version is needed at all. In theory - appending to list_display should be fairly safe - it's the register/unregister that could cause problems)

andybak avatar Jun 05 '17 08:06 andybak

I agree on the point to move the HijackUserAdminMixin to a separate file, but why is it not possible to import the HijackUserAdminMixin from the admin module?

The register/unregister code is only executed when the HIJACK_REGISTER_ADMIN is set to True. You always can modify this and the register/unregister code wouldn't be executed.

The non-mixin version is used for this app to work "out-of-the-box", so users will only have to pip install an can use the app without further changes.

walterrenner avatar Jan 26 '18 13:01 walterrenner

The register/unregister code is only executed when the HIJACK_REGISTER_ADMIN is set to True.

Hmmmm. It's possible I just didn't spot this at the time. However that setting defaults to True and it's a bit messy.

Someone has to:

a) Make the connection between the import problem and the existence of that setting b) Patch their settings to solve the problem

Isn't it cleaner to set up the file structure in such a way that it "just works"?

andybak avatar Jan 29 '18 12:01 andybak

@Mogost can you add a note explaining how this was completed?

andybak avatar May 06 '24 19:05 andybak

@Mogost can you add a note explaining how this was completed?

This package is abandoned. (actually integrated in the main package). You can follow the doc. https://django-hijack.readthedocs.io/en/latest/#django-admin-integration I don't think this problem is still actual for current implementation.

Mogost avatar May 06 '24 20:05 Mogost