django-permanent 1.1.6__tar.gz → 2.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. django_permanent-2.0.1/CHANGES.md +229 -0
  2. django_permanent-2.0.1/LICENSE +29 -0
  3. django_permanent-2.0.1/MANIFEST.in +4 -0
  4. django_permanent-2.0.1/PKG-INFO +295 -0
  5. django_permanent-2.0.1/README.md +241 -0
  6. django_permanent-2.0.1/django_permanent/__init__.py +2 -0
  7. django_permanent-2.0.1/django_permanent/checks.py +58 -0
  8. django_permanent-2.0.1/django_permanent/deletion.py +159 -0
  9. {django-permanent-1.1.6 → django_permanent-2.0.1}/django_permanent/managers.py +7 -9
  10. {django-permanent-1.1.6 → django_permanent-2.0.1}/django_permanent/models.py +10 -15
  11. {django-permanent-1.1.6 → django_permanent-2.0.1}/django_permanent/query.py +64 -63
  12. django_permanent-2.0.1/django_permanent/related.py +135 -0
  13. {django-permanent-1.1.6 → django_permanent-2.0.1}/django_permanent/settings.py +3 -1
  14. django_permanent-2.0.1/django_permanent/signals.py +4 -0
  15. django_permanent-2.0.1/django_permanent/tests/cases.py +620 -0
  16. {django-permanent-1.1.6 → django_permanent-2.0.1}/django_permanent/tests/test_app/models.py +39 -9
  17. django_permanent-2.0.1/django_permanent.egg-info/PKG-INFO +295 -0
  18. {django-permanent-1.1.6 → django_permanent-2.0.1}/django_permanent.egg-info/SOURCES.txt +4 -1
  19. django_permanent-2.0.1/django_permanent.egg-info/requires.txt +10 -0
  20. {django-permanent-1.1.6 → django_permanent-2.0.1}/setup.cfg +0 -1
  21. django_permanent-2.0.1/setup.py +53 -0
  22. django-permanent-1.1.6/MANIFEST.in +0 -2
  23. django-permanent-1.1.6/PKG-INFO +0 -150
  24. django-permanent-1.1.6/README.rst +0 -129
  25. django-permanent-1.1.6/django_permanent/deletion.py +0 -109
  26. django-permanent-1.1.6/django_permanent/related.py +0 -74
  27. django-permanent-1.1.6/django_permanent/signals.py +0 -4
  28. django-permanent-1.1.6/django_permanent/tests/cases.py +0 -305
  29. django-permanent-1.1.6/django_permanent/tests/test_app/__init__.py +0 -0
  30. django-permanent-1.1.6/django_permanent.egg-info/PKG-INFO +0 -150
  31. django-permanent-1.1.6/django_permanent.egg-info/requires.txt +0 -1
  32. django-permanent-1.1.6/setup.py +0 -40
  33. {django-permanent-1.1.6 → django_permanent-2.0.1}/django_permanent/tests/__init__.py +0 -0
  34. {django-permanent-1.1.6/django_permanent → django_permanent-2.0.1/django_permanent/tests/test_app}/__init__.py +0 -0
  35. {django-permanent-1.1.6 → django_permanent-2.0.1}/django_permanent.egg-info/dependency_links.txt +0 -0
  36. {django-permanent-1.1.6 → django_permanent-2.0.1}/django_permanent.egg-info/top_level.txt +0 -0
@@ -0,0 +1,229 @@
1
+ # CHANGELOG
2
+
3
+ ## 2.0.1 (2026-11-12)
4
+
5
+ - Allow Django 6.x: dependency range is now `Django>=4.2,<7.0` (#2, thanks @bashu)
6
+ - Add Django 6.0, 6.1 and Python 3.13, 3.14, 3.15 trove classifiers
7
+ - CI: test every Django 4.2–6.1 release on each Python version it officially supports (3.10–3.15)
8
+ - CI: add a job for the newest Django alpha/beta/rc (allowed to fail)
9
+ - CI: fix coverage report and Coveralls upload, which never ran because of mismatched matrix conditions
10
+
11
+
12
+ ## 2.0.0 (2026-02-07)
13
+
14
+ **Related Issues & PRs from MnogoByte/django-permanent:**
15
+ - Closes MnogoByte/django-permanent#53 - Cannot restore based on removed date
16
+ - Closes MnogoByte/django-permanent#75 - get related object for all_objects
17
+ - Closes MnogoByte/django-permanent#78 - Error on django > 3 when django-utils-six is not installed
18
+ - Closes MnogoByte/django-permanent#79 - Update deletion.py (same as #78)
19
+ - Closes MnogoByte/django-permanent#69 - Installation instructions
20
+ - Closes MnogoByte/django-permanent#66 - How is restore_on_create supposed to work?
21
+ - Closes MnogoByte/django-permanent#67 - README: Improved description
22
+ - Closes MnogoByte/django-permanent#26 - Reorganize generic code (removed 15+ version checks)
23
+ - Closes MnogoByte/django-permanent#18 - Implement future imports (not needed for Python 3.10+)
24
+
25
+ ### Breaking Changes
26
+
27
+ - **Minimum Django version: 4.2 LTS** (supports Django 4.2-5.2, experimental support for Django 6.0, tested with Django 7.0 dev)
28
+ - **Minimum Python version: 3.10** (supports 3.10, 3.11, 3.12)
29
+ - Dropped Django 1.x, 2.x, 3.x support
30
+ - Dropped Python 2.7, 3.4-3.9 support
31
+ - Removed django-model-utils dependency
32
+
33
+ ### Improvements
34
+
35
+ - Modernized codebase for Django 4.2+
36
+ - Removed Python 2/six dependencies
37
+ - Removed 15+ version compatibility checks
38
+ - Simplified QuerySet and Manager implementations
39
+ - Updated for Django 5.2 API changes (Collector.delete, ForeignObject.get_extra_restriction, Signal)
40
+ - All 44 tests passing with Django 4.2-7.0 dev - 100% pass rate, NO SKIPS! ✅
41
+ - Migrated CI/CD from Travis CI to GitHub Actions
42
+ - Converted documentation from RST to Markdown (README.md, CHANGES.md)
43
+ - Added explicit LICENSE file (BSD)
44
+
45
+ ### CI/CD Enhancements
46
+
47
+ - Added automated PyPI publishing workflow (GitHub Actions)
48
+ - Automatically publishes to PyPI when version tag is pushed
49
+ - Creates GitHub releases with release notes
50
+ - Auto-updates CHANGES.md with next version template after release
51
+ - Improved test infrastructure:
52
+ - Added extras_require for test and dev dependencies (coverage, flake8, coveralls)
53
+ - Added TEST_VERBOSITY environment variable support for flexible test output
54
+ - Improved coverage reporting and Coveralls integration
55
+
56
+ ### New Features
57
+
58
+ - Added Django System Check (W001) to detect problematic PermanentModel configurations
59
+ - Warns when PermanentModel has CASCADE ForeignKey to non-PermanentModel
60
+ - Helps prevent IntegrityError that occurs when the related non-PermanentModel is deleted
61
+ - Provides helpful suggestions: make related model PermanentModel, use SET_NULL, or use DO_NOTHING
62
+
63
+ ### Async Support
64
+
65
+ - **Refactored from thread-local variables to contextvars for async-safe operation**
66
+ - All deletion and query context handling now properly supports asyncio
67
+ - `_show_all_permanent` and `_is_deleting` now use `contextvars.ContextVar` instead of thread locals
68
+ - Context managers `deletion_context()` and `show_all_context()` are fully async-safe
69
+ - Prevents race conditions in async environments (ASGI, async views, async ORM operations)
70
+ - **Django async ORM support**: Works correctly with Django's async QuerySet API (acount, afirst, aget, etc.)
71
+ - **Future-proof**: Ready for Django's continued async expansion in versions 6.0 and 7.0
72
+
73
+ ### Bug Fixes from MnogoByte Fork
74
+
75
+ - Fixed MnogoByte/django-permanent#53: `restore()` now correctly respects user filters on `removed` field
76
+ - Previously `QuerySet.filter(removed__range=(start, end)).restore()` would restore ALL deleted objects
77
+ - Now only objects matching the filter criteria are restored
78
+ - Improved `_unpatch()` to distinguish automatic patches from user filters
79
+ - Added test case `test_restore_with_date_filter`
80
+
81
+ - Fixed MnogoByte/django-permanent#75: Access deleted related objects via `show_all_context()`
82
+ - Related objects can now be accessed when soft-deleted using `show_all_context()` context manager
83
+ - Example: `with show_all_context(): obj.foreign_key` now works for deleted related objects
84
+ - Improved `get_queryset_patch()` to respect `show_all_context()` setting
85
+ - Added test case `test_related_object_from_all_objects`
86
+
87
+ - Fixed MnogoByte/django-permanent#78: Removed `django.utils.six` dependency (already fixed by dropping Python 2)
88
+
89
+ - Improved documentation (MnogoByte/django-permanent#69, #66, #67):
90
+ - Added Installation section to README with requirements
91
+ - Improved `restore_on_create` documentation with detailed examples
92
+ - Added section on accessing deleted related objects
93
+
94
+ ### Test Changes
95
+
96
+ - Added test_cascade_to_non_permanent_model_warning to verify system check works correctly
97
+ - Removed test_m2m_manager_delete (tested invalid configuration that violates W001 check)
98
+ - Removed test_m2m_select_related (obsolete for Django 1.8+, functionality covered by other tests)
99
+
100
+ ### Technical Changes
101
+
102
+ - **Migrated to contextvars** for async-safe context management (replacing thread-local variables)
103
+ - Removed six.iteritems/itervalues usage
104
+ - Updated transaction handling (removed commit_on_success_unless_managed)
105
+ - Fixed Collector.delete return value for Django 1.9+ behavior
106
+ - Updated Signal() to remove deprecated providing_args parameter
107
+ - Updated ForeignObject.get_extra_restriction signature for Django 5.2
108
+ - Updated QuerySet._update() signature to use *args for Django 4.2-5.2 compatibility (returning_fields parameter)
109
+ - Fixed Query.clear_ordering() parameter (force_empty → force)
110
+ - Removed ValuesQuerySet/ValuesListQuerySet custom implementations
111
+ - Simplified manager system (removed PassThroughManager fallback)
112
+ - Added DEFAULT_AUTO_FIELD='django.db.models.BigAutoField' in test configuration for Django 3.2+ compatibility
113
+ - Fixed setup.py to reference README.md instead of README.rst
114
+
115
+ ## 1.1.6 (2017-05-04)
116
+
117
+ - Missing related model all_objects manager bug #65 (thanks @kregoslup)
118
+
119
+ ## 1.1.5 (2017-03-02)
120
+
121
+ - readme code highlight (thanks @bashu)
122
+ - queryset values method bug #62 (thanks @tjacoel)
123
+
124
+ ## 1.1.4 (2016-09-15)
125
+
126
+ - django 1.10 support #58 (thanks @atin65536)
127
+
128
+ ## 1.1.3 (2016-09-08)
129
+
130
+ - django 1.9 support #56 (thanks @atin65536)
131
+ - values_list support #56 (thanks @atin65536)
132
+ - QuerySet pickling bug #55 (thanks @atin65536)
133
+
134
+ ## 1.1.2 (2016-03-30)
135
+
136
+ - running setup.py without django bug #47
137
+
138
+ ## 1.1.1 (2016-03-16)
139
+
140
+ - ForeignKey on_delete behaviour bug (thanks @atin65536)
141
+
142
+ ## 1.1.0 (2016-03-16)
143
+
144
+ - Django 1.9 support
145
+ - QuerySetManager support
146
+ - Python 3.5 support
147
+ - Fixed latest supported model_utls version
148
+ - Documentation fixes
149
+ - inf recursion on restore_on_create bug
150
+ - Python 2.6 support dropped
151
+
152
+ Thanks to @aidanlister, @atin65536 and @jarekwg, you are awesome!
153
+
154
+ ## 1.0.12 (2015-11-27)
155
+
156
+ - added pre_restore, post_restore signals thanks atin65536
157
+
158
+ ## 1.0.11 (2015-05-29)
159
+
160
+ - Fixed deepcopy()-ing PermanentQuerySet #30
161
+ - all_objects.select_related bug #31
162
+
163
+ ## 1.0.10 (2015-04-03)
164
+
165
+ - Skip test_m2m_select_related test on Django 1.8 #27
166
+ - Manager isn't available; PermanentModel is abstract #24
167
+ - Atomic only for django >= 1.8 #21
168
+ - Django 1.8 support
169
+ - ReverseSingleRelatedObjectDescriptor patch Bug #25
170
+ - Do not try to restore deleted object if it is created already deleted #23
171
+
172
+ ## 1.0.9 (2015-04-02)
173
+
174
+ - Transaction handling backward compatibility #21
175
+ - replaced create_many_related_manager patching with get_extra_restriction patch
176
+ - fixed removable m2m through #22
177
+
178
+ ## 1.0.8 (2015-03-27)
179
+
180
+ - Returned force argument
181
+ - Replace commit_on_success_unless_managed by atomic (thanks David Fischer)
182
+ - Find packages recursively (thanks David Fischer)
183
+ - Make setup.py executable (thanks David Fischer)
184
+
185
+ ## 1.0.7 (2015-03-24)
186
+
187
+ - Setting trigger field for all removed objects
188
+ - Trigger field model save now affects all objects
189
+
190
+ ## 1.0.6 (2015-03-24)
191
+
192
+ - Fixed PermanentModel.restore() fail
193
+ - PermanentModel.delete() now sets removed attribute
194
+
195
+ ## 1.0.5 (2015-03-23)
196
+
197
+ - Removed fast_deletes fix
198
+ - create_many_related_manager patch (For proper m2m)
199
+ - Proper Collector patching
200
+ - proper Query patching/unpatching
201
+ - restore_on_create feature
202
+
203
+ ## 1.0.4 (2015-03-17)
204
+
205
+ - Many-to-many relations support
206
+ - get_restore_or_create bug
207
+ - added MIDDLEWARE_CLASSES to reduce Django 1.7 output
208
+
209
+ ## 1.0.3 (2015-03-17)
210
+
211
+ - Related manager tests
212
+ - Double delete tests
213
+ - Disabled PermanentModels foreign key updates
214
+ - _base_manager override
215
+ - Django 1.7 get_restore_or_create bug
216
+ - Django 1.7 test structure support
217
+ - wrong version in master
218
+ - include tests into the package
219
+ - Fixed get_restore_or_create hardcoded field name
220
+
221
+ ## 1.0.2 (2014-02-05)
222
+
223
+ - get_restore_or_create bug
224
+ - Trigger field customisation support
225
+
226
+ ## 1.0.1 (2014-02-03)
227
+
228
+ - Prefetch related bug
229
+ - Django 1.6 transactions support
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2013-2026, Alexander Klimenko
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,4 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGES.md
4
+ recursive-include django_permanent *.py
@@ -0,0 +1,295 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-permanent
3
+ Version: 2.0.1
4
+ Summary: Yet another approach to provide soft (logical) delete or masking (thrashing) django models instead of deleting them physically from db.
5
+ Home-page: https://github.com/meteozond/django-permanent
6
+ Author: Alexander Klimenko
7
+ Author-email: alex@erix.ru
8
+ License: BSD
9
+ Keywords: django,delete,undelete,safedelete,remove,restore,softdelete,logicaldelete,trash
10
+ Classifier: Framework :: Django
11
+ Classifier: Framework :: Django :: 4.2
12
+ Classifier: Framework :: Django :: 5.0
13
+ Classifier: Framework :: Django :: 5.1
14
+ Classifier: Framework :: Django :: 5.2
15
+ Classifier: Framework :: Django :: 6.0
16
+ Classifier: Framework :: Django :: 6.1
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Intended Audience :: System Administrators
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Topic :: Software Development
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Programming Language :: Python :: 3.14
27
+ Classifier: Programming Language :: Python :: 3.15
28
+ Classifier: Development Status :: 5 - Production/Stable
29
+ Classifier: License :: OSI Approved :: BSD License
30
+ Requires-Python: >=3.10
31
+ Description-Content-Type: text/markdown
32
+ License-File: LICENSE
33
+ Requires-Dist: Django<7.0,>=4.2
34
+ Provides-Extra: test
35
+ Requires-Dist: coverage>=7.0; extra == "test"
36
+ Requires-Dist: flake8>=6.0; extra == "test"
37
+ Provides-Extra: dev
38
+ Requires-Dist: coverage>=7.0; extra == "dev"
39
+ Requires-Dist: flake8>=6.0; extra == "dev"
40
+ Requires-Dist: coveralls>=3.3; extra == "dev"
41
+ Dynamic: author
42
+ Dynamic: author-email
43
+ Dynamic: classifier
44
+ Dynamic: description
45
+ Dynamic: description-content-type
46
+ Dynamic: home-page
47
+ Dynamic: keywords
48
+ Dynamic: license
49
+ Dynamic: license-file
50
+ Dynamic: provides-extra
51
+ Dynamic: requires-dist
52
+ Dynamic: requires-python
53
+ Dynamic: summary
54
+
55
+ # Django Permanent
56
+
57
+ Yet another approach to provide soft (logical) delete or masking (thrashing) django models instead of deleting them physically from db.
58
+
59
+ [![Tests](https://github.com/meteozond/django-permanent/actions/workflows/test.yml/badge.svg)](https://github.com/meteozond/django-permanent/actions/workflows/test.yml)
60
+
61
+ ## Installation
62
+
63
+ Install using pip:
64
+
65
+ ```bash
66
+ pip install django-permanent
67
+ ```
68
+
69
+ Or install from source:
70
+
71
+ ```bash
72
+ git clone https://github.com/meteozond/django-permanent.git
73
+ cd django-permanent
74
+ python setup.py install
75
+ ```
76
+
77
+ **Requirements:**
78
+ - Python 3.10+
79
+ - Django 4.2–6.x
80
+
81
+ **Setup:**
82
+
83
+ Add `django_permanent` to your `INSTALLED_APPS`:
84
+
85
+ ```python
86
+ INSTALLED_APPS = [
87
+ ...
88
+ 'django_permanent',
89
+ ]
90
+ ```
91
+
92
+ This enables Django System Checks that warn about problematic configurations.
93
+
94
+ ## Quick Start
95
+
96
+ To create a non-deletable model just inherit it from `PermanentModel`:
97
+
98
+ ```python
99
+ class MyModel(PermanentModel):
100
+ pass
101
+ ```
102
+
103
+ It automatically changes delete behaviour to hide objects instead of deleting them:
104
+
105
+ ```python
106
+ >>> a = MyModel.objects.create(pk=1)
107
+ >>> b = MyModel.objects.create(pk=2)
108
+ >>> MyModel.objects.count()
109
+ 2
110
+ >>> a.delete()
111
+ >>> MyModel.objects.count()
112
+ 1
113
+ ```
114
+
115
+ To recover a deleted object just call its `restore` method:
116
+
117
+ ```python
118
+ >>> a.restore()
119
+ >>> MyModel.objects.count()
120
+ 2
121
+ ```
122
+
123
+ Use the `force` kwarg to enforce physical deletion:
124
+
125
+ ```python
126
+ >>> a.delete(force=True) # Will act as the default django delete
127
+ >>> MyModel._base_manager.count()
128
+ 0
129
+ ```
130
+
131
+ ### Restore on Create
132
+
133
+ If you want `create()` to restore deleted objects instead of raising an integrity error on unique constraints, use the `restore_on_create` option:
134
+
135
+ ```python
136
+ class Article(PermanentModel):
137
+ title = models.CharField(max_length=100, unique=True)
138
+
139
+ class Permanent:
140
+ restore_on_create = True
141
+ ```
142
+
143
+ **How it works:**
144
+
145
+ When `restore_on_create = True`, calling `Model.objects.create(**kwargs)` will:
146
+ 1. First try to find a matching object (including soft-deleted ones)
147
+ 2. If found and deleted: restore it and update with new kwargs
148
+ 3. If found and not deleted: return the existing object
149
+ 4. If not found: create a new object
150
+
151
+ **Example:**
152
+
153
+ ```python
154
+ >>> article = Article.objects.create(title="Django Tips")
155
+ >>> article.delete() # Soft delete
156
+ >>> Article.objects.count()
157
+ 0
158
+
159
+ # Without restore_on_create: would raise IntegrityError
160
+ # With restore_on_create: restores the deleted article
161
+ >>> article2 = Article.objects.create(title="Django Tips")
162
+ >>> article2.pk == article.pk # Same object!
163
+ True
164
+ >>> Article.objects.count()
165
+ 1
166
+ ```
167
+
168
+ **Note:** This feature is most useful for models with unique constraints where you want to "resurrect" deleted objects rather than creating duplicates.
169
+
170
+ ## Managers
171
+
172
+ It changes the default model manager to ignore deleted objects, adding a `deleted_objects` manager to see them instead:
173
+
174
+ ```python
175
+ >>> MyModel.objects.count()
176
+ 2
177
+ >>> a.delete()
178
+ >>> MyModel.objects.count()
179
+ 1
180
+ >>> MyModel.deleted_objects.count()
181
+ 1
182
+ >>> MyModel.all_objects.count()
183
+ 2
184
+ >>> MyModel._base_manager.count()
185
+ 2
186
+ ```
187
+
188
+ ### Accessing Deleted Related Objects
189
+
190
+ By default, accessing a foreign key to a deleted object will raise `DoesNotExist`. Use `show_all_context()` to access deleted related objects:
191
+
192
+ ```python
193
+ from django_permanent.related import show_all_context
194
+
195
+ # Create models with relationship
196
+ parent = ParentModel.objects.create(name="parent")
197
+ child = ChildModel.objects.create(parent=parent)
198
+
199
+ # Soft delete parent
200
+ parent.delete()
201
+
202
+ # Without show_all_context: raises DoesNotExist
203
+ child.parent # Raises ParentModel.DoesNotExist
204
+
205
+ # With show_all_context: can access deleted parent
206
+ with show_all_context():
207
+ print(child.parent.name) # Works! Returns "parent"
208
+ ```
209
+
210
+ **Note:** This is useful when you need to access relationships to soft-deleted objects, for example in admin interfaces or audit logs.
211
+
212
+ ## QuerySet
213
+
214
+ The `QuerySet.delete` method will act as the default django delete, with one exception - objects of models subclassing `PermanentModel` will be marked as deleted; the rest will be deleted physically:
215
+
216
+ ```python
217
+ >>> MyModel.objects.all().delete()
218
+ ```
219
+
220
+ You can still force django query set physical deletion:
221
+
222
+ ```python
223
+ >>> MyModel.objects.all().delete(force=True)
224
+ ```
225
+
226
+ ## Using custom querysets
227
+
228
+ 1. Inherit your query set from `PermanentQuerySet`:
229
+
230
+ ```python
231
+ class ServerFileQuerySet(PermanentQuerySet)
232
+ pass
233
+ ```
234
+
235
+ 2. Wrap `PermanentQuerySet` or `DeletedQuerySet` in you model manager declaration:
236
+
237
+ ```python
238
+ class MyModel(PermanentModel)
239
+ objects = MultiPassThroughManager(ServerFileQuerySet, NonDeletedQuerySet)
240
+ deleted_objects = MultiPassThroughManager(ServerFileQuerySet, DeletedQuerySet)
241
+ all_objects = MultiPassThroughManager(ServerFileQuerySet, PermanentQuerySet)
242
+ ```
243
+
244
+ ## Method `get_restore_or_create`
245
+
246
+ 1. Check for existence of the object.
247
+ 2. Restore it if it was deleted.
248
+ 3. Create a new one, if it was never created.
249
+
250
+ ## Field name
251
+
252
+ The default field named is 'removed', but you can override it with the PERMANENT_FIELD variable in settings.py:
253
+
254
+ ```python
255
+ PERMANENT_FIELD = 'deleted'
256
+ ```
257
+
258
+ ## Requirements
259
+
260
+ - Django 4.2–6.x
261
+ - Python 3.10–3.15
262
+
263
+ ## Testing
264
+
265
+ The project uses GitHub Actions for continuous integration.
266
+
267
+ **Run tests locally using act (GitHub Actions locally):**
268
+
269
+ ```bash
270
+ # Install act (macOS)
271
+ brew install act
272
+
273
+ # Run all tests in parallel
274
+ act
275
+
276
+ # Run specific Python version
277
+ act --matrix python-version:3.11
278
+
279
+ # Run specific Python/Django combination
280
+ act --matrix python-version:3.11 --matrix django-version:"Django>=4.2,<5.0"
281
+ ```
282
+
283
+ **Run tests directly:**
284
+
285
+ ```bash
286
+ # Install dependencies
287
+ pip install "Django>=4.2,<5.0" coverage flake8
288
+
289
+ # Run linter
290
+ flake8 django_permanent
291
+
292
+ # Run tests with coverage
293
+ coverage run runtests.py
294
+ coverage report
295
+ ```