Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve detection of first party apps. #62

Closed
wants to merge 1 commit into from

Conversation

mbaechtold
Copy link

@mbaechtold mbaechtold commented Apr 1, 2021

Django apps are sometimes referenced with their dotted path in settings.FIRST_PARTY_APPS, e.g. myproject.myapp. But the label of the app config is the right most part of the path, e.g. myapp which is not in settings.FIRST_PARTY_APPS and thus the app will not be considered a first party app.

We can improve this by looking at the name of the app config, which should normally correspond to the dotted path of the app.

A similar problem arises if settings.FIRST_PARTY_APPS contains the dotted path to the app's app config class, e.g. myproject.myapp.apps.MyAppConfigSubclass. But that can be worked around by putting default_app_config into the apps __init__.py, so we are not addressing that right now.

Django apps sometimes are referenced with their dotted path in `settings.FIRST_PARTY_APPS`, e.g. `myproject.myapp`. But the label of the app config is the right most part of the path, e.g. `myapp` which is not in `settings.FIRST_PARTY_APPS` and thus the app will not be considered a first party app.

We can improve this by looking at the name of the app config, which should normally correspond to the dotted path of the app.

A similar problem arises if `settings.FIRST_PARTY_APPS` contains the dotted path to the app's app config class, e.g. `myproject.myapp.apps.MyAppConfigSubclass`. But that can be worked around by putting `default_app_config` into the apps `__init__.py`, so we are not addressing that right now.
@adamchainz
Copy link
Owner

Thanks for the report. I decided to take a different approach in #62 that calls AppConfig.create to match exactly Django's handling of the names in INSTALLED_APPS, so that there's no need to worry about handling AppConfig differently, or the changes to default_app_config in Django 3.2.

Released in 1.6.0, try it out!

@adamchainz adamchainz closed this Apr 8, 2021
@mbaechtold mbaechtold deleted the mba/first-party-apps branch April 8, 2021 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants