﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30950	Replace __file__ with importlib.resources	John Vandenberg	nobody	"`__file__` is an optional attribute of modules, and it either is added/modified by magic logic like Nuitka, PyInstaller, cx_Freeze, and each new freezer needs to add per-package hacks to get Django working, and need to be fixed whenever Django internals change, or isnt provided by freezers like PyOxidizer which refuse to play that cat & mouse game (c.f. https://github.com/indygreg/PyOxidizer/issues/69).

The solution is to use `importlib.resources` where-ever the code is accessing data files inside the Django package, or other modules.

e.g. under PyOxidizer:
```
  File ""django.test"", line 3, in <module>
  File ""django.test.client"", line 14, in <module>
  File ""django.core.handlers.base"", line 8, in <module>
  File ""django.urls"", line 1, in <module>
  File ""django.urls.base"", line 8, in <module>
  File ""django.urls.exceptions"", line 1, in <module>
  File ""django.http"", line 5, in <module>
  File ""django.http.response"", line 15, in <module>
  File ""django.core.serializers"", line 23, in <module>
  File ""django.core.serializers.base"", line 7, in <module>
  File ""django.db.models"", line 3, in <module>
  File ""django.db.models.aggregates"", line 5, in <module>
  File ""django.db.models.expressions"", line 8, in <module>
  File ""django.db.models.fields"", line 11, in <module>
  File ""django.forms"", line 6, in <module>
  File ""django.forms.boundfield"", line 4, in <module>
  File ""django.forms.widgets"", line 26, in <module>
  File ""django.forms.renderers"", line 16, in <module>
NameError: name '__file__' is not defined
```

To make this feature contained, I would limit it to runtime code of Django, and exclude instances of `__file__` in docs and templates deployed into new projects which need to be ""manage.py-relative-paths"", such as those in https://github.com/django/django/pull/12005"	Bug	new	Core (Other)	dev	Normal		freezers	William Schwartz Ülgen Sarıkavak	Someday/Maybe	0	0	0	0	0	0
