[Django] #32382: Django 3.2 app config search prevents single-file apps

24 views
Skip to first unread message

Django

unread,
Jan 25, 2021, 5:53:42 AM1/25/21
to django-...@googlegroups.com
#32382: Django 3.2 app config search prevents single-file apps
------------------------------------------------+------------------------
Reporter: Adam Johnson | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (Other) | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
My third party package django-read-only is implemented as a single file
([pre-3.1-support source](https://github.com/adamchainz/django-read-
only/blob/e95530273fd75da34fd77b1625549ffd3840beaa/src/django_read_only.py)).
With Django <3.2's `default_app_config`, it could point to its app config
within the same module by defining `default_app_config`.

Now the AppConfig logic *requires* an `apps` submodule, which means apps
cannot be single-file modules but have to be packages.

To work around this in django-read-only I made it into package, left all
the logic in its `__init__.py`, and added a "dummy" `apps.py` that has
only the line `from django_read_only import DjangoReadOnlyAppConfig`
(moving the app config would complicate its implementation).

Could we make the apps logic not search for an 'apps' submodule in the
case of non-package modules, and instead check in the base module?

--
Ticket URL: <https://code.djangoproject.com/ticket/32382>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 25, 2021, 5:54:23 AM1/25/21
to django-...@googlegroups.com
#32382: Django 3.2 app config search prevents single-file apps
-------------------------------------+-------------------------------------

Reporter: Adam Johnson | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Core (Other) | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Adam Johnson:

Old description:

> My third party package django-read-only is implemented as a single file
> ([pre-3.1-support source](https://github.com/adamchainz/django-read-
> only/blob/e95530273fd75da34fd77b1625549ffd3840beaa/src/django_read_only.py)).
> With Django <3.2's `default_app_config`, it could point to its app config
> within the same module by defining `default_app_config`.
>
> Now the AppConfig logic *requires* an `apps` submodule, which means apps
> cannot be single-file modules but have to be packages.
>
> To work around this in django-read-only I made it into package, left all
> the logic in its `__init__.py`, and added a "dummy" `apps.py` that has
> only the line `from django_read_only import DjangoReadOnlyAppConfig`
> (moving the app config would complicate its implementation).
>
> Could we make the apps logic not search for an 'apps' submodule in the
> case of non-package modules, and instead check in the base module?

New description:

My third party package django-read-only is implemented as a single file

([https://github.com/adamchainz/django-read-
only/blob/e95530273fd75da34fd77b1625549ffd3840beaa/src/django_read_only.py
pre-3.1-support source]). With Django <3.2's `default_app_config`, it


could point to its app config within the same module by defining
`default_app_config`.

Now the AppConfig logic *requires* an `apps` submodule, which means apps
cannot be single-file modules but have to be packages.

To work around this in django-read-only I made it into package, left all
the logic in its `__init__.py`, and added a "dummy" `apps.py` that has
only the line `from django_read_only import DjangoReadOnlyAppConfig`
(moving the app config would complicate its implementation).

([https://github.com/adamchainz/django-read-
only/pull/37/commits/392056b4bbc1eb1ce25b159134e2ab114ca0cdcb commit ])

Could we make the apps logic not search for an 'apps' submodule in the
case of non-package modules, and instead check in the base module?

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32382#comment:1>

Django

unread,
Jan 25, 2021, 6:43:59 AM1/25/21
to django-...@googlegroups.com
#32382: Django 3.2 app config search prevents single-file apps
-------------------------------------+-------------------------------------

Reporter: Adam Johnson | Owner: nobody
Type: | Status: closed
Cleanup/optimization |

Component: Core (Other) | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => needsinfo


Comment:

`django_read_only==1.2.0` works fine as a single file (without
`default_app_config`) when you will use
`django_read_only.DjangoReadOnlyAppConfig` in the `INSTALLED_APPS`,
instead of `django_read_only`. It's niche, so I'm not sure if supporting
default app configs in the base module is worth additional complexity and
side-effects (such as e.g. [https://github.com/django/django-contrib-
comments/pull/168#issuecomment-766720277 clashes]), but we could evaluate
a patch.

--
Ticket URL: <https://code.djangoproject.com/ticket/32382#comment:2>

Django

unread,
Jan 25, 2021, 10:46:18 AM1/25/21
to django-...@googlegroups.com
#32382: Django 3.2 app config search prevents single-file apps
-------------------------------------+-------------------------------------

Reporter: Adam Johnson | Owner: nobody
Type: | Status: closed
Cleanup/optimization |

Component: Core (Other) | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Adam Johnson):

Yes that's true. It's probably not worth complicating things.

--
Ticket URL: <https://code.djangoproject.com/ticket/32382#comment:3>

Django

unread,
Jan 26, 2021, 12:09:08 AM1/26/21
to django-...@googlegroups.com
#32382: Django 3.2 app config search prevents single-file apps
-------------------------------------+-------------------------------------

Reporter: Adam Johnson | Owner: nobody
Type: | Status: closed
Cleanup/optimization |

Component: Core (Other) | Version: 3.2
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* resolution: needsinfo => wontfix


--
Ticket URL: <https://code.djangoproject.com/ticket/32382#comment:4>

Reply all
Reply to author
Forward
0 new messages