django-modeladmin-reorder icon indicating copy to clipboard operation
django-modeladmin-reorder copied to clipboard

Handle admin sidebar in Django 3.1

Open frnhr opened this issue 5 years ago • 22 comments

Starting from 3.1, Django has a sidebar in the admin. The sidebar looks very much like the apps and models list on admin dashboard. Perhaps django-modelsadmin-reorder should handle the sidebar as well, so that it lists the same models as on the dashboard.

Select_site_to_change___STEMI

frnhr avatar May 15 '20 21:05 frnhr

I created a PR for that https://github.com/mishbahr/django-modeladmin-reorder/pull/49 You can install admin_reorder from my fork for now. pip install git+git://github.com/bloodwithmilk25/django-modeladmin-reorder.git@master

bloodwithmilk25 avatar Aug 17 '20 09:08 bloodwithmilk25

I just upgraded to Django 3.1 and started using django-modeladmin-reorder and immediately hit this too. @bloodwithmilk25 , your PR looks good - hoping it will get merged 😄

jongracecox avatar Aug 24 '20 22:08 jongracecox

The changes made to the middleware would break the packages compatibility to python 2 versions of django

T-101 avatar Nov 13 '20 15:11 T-101

Three words for Python 2: EOL 😁

frnhr avatar Nov 13 '20 21:11 frnhr

while those three words are true, it doesn't mean there aren't system still running it :) a solution is available that both fixes the issue with django 3.1 while retaining backwards compatibility

T-101 avatar Nov 15 '20 16:11 T-101

Hi @mishbahr , Any chance to merge #49 and release it at PyPI?

DmytroLitvinov avatar Nov 17 '20 19:11 DmytroLitvinov

while those three words are true, it doesn't mean there aren't system still running it :) a solution is available that both fixes the issue with django 3.1 while retaining backwards compatibility

I think you are right. PR #49 aims to solve the problem with the sidebar. Changes from string_types to str should not be a hidden target for this PR #49 ...

nikitron avatar Nov 24 '20 09:11 nikitron

@mishbahr +1 on getting this merged and released.

paulschreiber avatar Dec 22 '20 16:12 paulschreiber

I tested it on Django 3.1.5 and it works! could you merge and publish? please. Thank you =)

bergran avatar Mar 03 '21 15:03 bergran

just added to project's urls.py

admin.autodiscover()
admin.site.enable_nav_sidebar = False

and this problem will be solved :)

Anastasiya-Taranova avatar Mar 15 '21 10:03 Anastasiya-Taranova

I created a PR for that #49 You can install admin_reorder from my fork for now. pip install git+git://github.com/bloodwithmilk25/django-modeladmin-reorder.git@master

Thanks! It worked quite well! I'm using jazzmin for the styling, it provides a dashboard and I don't know why when I navigate to the dashboard the sidebar stops being organized following the configuration. Any suggestion about how to work it out? Thank you!

martinnavarro198 avatar May 06 '21 07:05 martinnavarro198

I created a PR for that #49 You can install admin_reorder from my fork for now. pip install git+git://github.com/bloodwithmilk25/django-modeladmin-reorder.git@master

Thank you, it worked for me :) Perfect

Kadermiyanyedi avatar Jun 04 '21 13:06 Kadermiyanyedi

Hi @mishbahr ,

If you need help with maintaining that project, let us know. Maybe we should transform it to JazzBand organization.

DmytroLitvinov avatar Jun 18 '21 09:06 DmytroLitvinov

I created a PR for that #49 You can install admin_reorder from my fork for now. pip install git+git://github.com/bloodwithmilk25/django-modeladmin-reorder.git@master

It doesn't work for Django 3.2.2

rikhtehgaran avatar Jun 25 '21 13:06 rikhtehgaran

I created a PR for that #49 You can install admin_reorder from my fork for now. pip install git+git://github.com/bloodwithmilk25/django-modeladmin-reorder.git@master

It doesn't work for Django 3.2.2

Are you using the master branch or that PR? I use commit SHA 6cc5060 which is from the PR, and it's been working well for me since I installed from that rather than the latest release. Currently on Django 3.2.5.

jgillard avatar Jul 14 '21 21:07 jgillard

I created a PR for that #49 You can install admin_reorder from my fork for now. pip install git+git://github.com/bloodwithmilk25/django-modeladmin-reorder.git@master

It doesn't work for Django 3.2.2

Are you using the master branch or that PR? I use commit SHA 6cc5060 which is from the PR, and it's been working well for me since I installed from that rather than the latest release. Currently on Django 3.2.5.

I've just run: pip install git+git://github.com/bloodwithmilk25/django-modeladmin-reorder.git@master

and nothing happened in output. Is it related to the Django version because mine is 3.2.2 Selection_010

rikhtehgaran avatar Jul 15 '21 11:07 rikhtehgaran

Hack middleware

class ModelAdminReorderWithNav(ModelAdminReorder):
    def process_template_response(self, request, response):

        if (
            getattr(response, 'context_data', None)
            and not response.context_data.get('app_list')
            and (available_apps := response.context_data.get('available_apps'))
        ):
            response.context_data['app_list'] = available_apps
            response = super().process_template_response(request, response)
            response.context_data['available_apps'] = response.context_data[
                'app_list'
            ]
            return response

        return super().process_template_response(request, response)

SergeyDubovitsky avatar May 30 '22 11:05 SergeyDubovitsky

Thx, @SergeyDubovitsky ! This works great. It can be used it like this:

  • Use from admin_reorder.middleware import ModelAdminReorder in the file
  • Put it e.g. in myapp/middleware, and in settings.py replace the admin_reorder middleware with myapp.middleware.ModelAdminReorderWithNav or similar

neuged avatar Oct 24 '22 16:10 neuged

I created a PR for that #49 You can install admin_reorder from my fork for now. pip install git+git://github.com/bloodwithmilk25/django-modeladmin-reorder.git@master

Thanks! It worked quite well! I'm using jazzmin for the styling, it provides a dashboard and I don't know why when I navigate to the dashboard the sidebar stops being organized following the configuration. Any suggestion about how to work it out? Thank you!

im also having the same issue is there a solution to fix the side bar as well im using Django==4.2.1

lenate-flycatch avatar Jun 27 '23 15:06 lenate-flycatch

@mishbahr please take a look at this. we really need to either support this project or transfer it to someone who'll be able to maintain it.

palvol avatar Aug 03 '23 14:08 palvol

either

my issue was fixed Thanks

lenate-flycatch avatar Aug 06 '23 10:08 lenate-flycatch

pip install git+git://github.com/bloodwithmilk25/django-modeladmin-reorder.git@master

I was desperately trying to make the nav bar work (the home page reordering was working but not the nav bar for some reason) and this solve the issue. I had to change git+git to git+https but worked like a charm - just plug and play. Hopefully this will be integrated in the lib, but in any case many thanks!

Svestis avatar Aug 11 '23 22:08 Svestis