CentreForDigitalHumanities / CentreForDigitalHumanities/django-shared-core
Fix file wrapper for Django 5.2
- Dominant language
- JavaScript
- Stars
- 1
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Django 5.2 introduces (and uses) the `Model._is_pk_set()` [method](https://docs.djangoproject.com/en/5.2/ref/models/instances/#django.db.models.Model._is_pk_set), which causes an error in `FileWrapper.__getattr__()`:
```
======================================================================
ERROR: test_tracked_url_generation (dev_files.tests.FileTests.test_tracked_url_generation)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/michael/cdh/django/dsc/django-shared-core/dev/dev_files/tests.py", line 765, in test_tracked_url_generation
obj.files.add(File(open(self.file_cat, mode='rb')))
File "/home/michael/cdh/django/dsc/django-shared-core/src/cdh/files/db/wrappers.py", line 482, in add
through_obj.save()
File "/home/michael/.local/share/virtualenvs/django-shared-core-q8WVdqSE/lib/python3.12/site-packages/django/db/models/base.py", line 857, in save
self._prepare_related_fields_for_save(operation_name="save")
File "/home/michael/.local/share/virtualenvs/django-shared-core-q8WVdqSE/lib/python3.12/site-packages/django/db/models/base.py", line 1238, in _prepare_related_fields_for_save
if not obj._is_pk_set():
^^^^^^^^^^^^^^
File "/home/michael/cdh/django/dsc/django-shared-core/src/cdh/files/db/wrappers.py", line 39, in __getattr__
raise AttributeError(f"No such attribute '{item}'")
AttributeError: No such attribute '_is_pk_set'
----------------------------------------------------------------------
```
Or better said, it doesn't know what to do with it. Django 5.2 required to reproduce.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.