CentreForDigitalHumanities / CentreForDigitalHumanities/django-shared-core

Django 5.2 - No such attribute '_is_pk_set' in wrappers.py

Open
#133 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Django 5.2 internally uses a new `_is_pk_set()` [1] method which is incorrectly raised by `FileWrapper.__get__()`.

You can test this in branch `feat/django-52`. Beware of local paths in `requirements.txt`.

1. https://docs.djangoproject.com/en/6.0/releases/5.2/#database-backend-api

```
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'
```

Paging @tymees for an opinion. I can probably figure this one out, just wondering if there's anything to look out for.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.