Giter Site home page Giter Site logo

lekjos / django-custom-admin-pages Goto Github PK

View Code? Open in Web Editor NEW
53.0 53.0 0.0 351 KB

A Django app that allows you to register class-based views to appear in Django admin.

License: BSD 3-Clause "New" or "Revised" License

Python 99.11% HTML 0.89%

django-custom-admin-pages's People

Contributors

dependabot[bot] avatar lekjos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

django-custom-admin-pages's Issues

App label issues when following dotted path convention

Describe the bug
Django recommends that for local apps, you specify the INSTALLED_APPS via the dotted path to the AppConfig (see INSTALLED_APPS).

In order to pass the check added by 1.2.2, the app_label needs to be the same string used INSTALLED_APPS. However, if this is used, then we can no longer match on app_label CustomAdminSite's get_app_list().

To Reproduce
Steps to reproduce the behavior:

  1. Have an app named "my_app" with AppConfig at my_app.apps.MyAppConfig.
  2. Add the dotted path to INSTALLED_APPS
  3. Create a View extendeing AdminBaseView, and use "my_app" as the app_label.

Expected behavior
Correct app is identified.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Mac OS 14.1.1
  • Browser Firefox (irrelevant)
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
I believe we would expect found to be set to True in this scenario (ref)

for app in app_list:
    if view_app_label == app.get("app_label", "").lower():
        found = True

But since it falls through, another issue occurs on line 210 because get_installed_apps() returns a flat list of strings, whereas app_list is a list of dicts containing 'name', 'app_label', etc.

This causes the following TypeError:

 File "<path>/.venv/lib/python3.11/site-packages/django_custom_admin_pages/admin.py", line 210, in get_app_list
   remaining_apps = set(set(get_installed_apps())).difference(app_list)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'dict'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.