Skip to content

Commit 8f7f96f

Browse files
Update docs for on_delete requirement in Filer fields for Django 5.1 (#1508)
* Update docs for on_delete requirement in Filer fields for Django 5.1 Update documentation to reflect the requirement of the `on_delete` parameter for `FilerFileField` and `FilerImageField`, ensuring compatibility with Django 5.1. Documentation: - Update documentation to indicate that the `on_delete` parameter is required when using `FilerFileField` and `FilerImageField`. - Add example code in the documentation showing proper field definition with the `on_delete` parameter. - Review and update other field examples in the documentation to ensure they include required parameters. Resolves #1506 * Collect upgrading info at one palce * Update version and changelog --------- Co-authored-by: sourcery-ai[bot] <sourcery-ai[bot]@users.noreply.github.com> Co-authored-by: Fabian Braun <fsbraun@gmx.de>
1 parent 93ffea5 commit 8f7f96f

File tree

6 files changed

+48
-28
lines changed

6 files changed

+48
-28
lines changed

CHANGELOG.rst

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
CHANGELOG
33
=========
44

5+
3.3.0 (2024-11-19)
6+
==================
7+
8+
* fix: Restrict upload of binary or unknown file types by default by @fsbraun in https://github.com/django-cms/django-filer/pull/1507
9+
* fix: remove extra brace in generated HTML of data-max-filesize attribute by @fabien-michel in https://github.com/django-cms/django-filer/pull/1502
10+
* fix: uploadButton data-max-filesize attribute is not passed to file-uploader by @fabien-michel in https://github.com/django-cms/django-filer/pull/1503
11+
* docs: Update for on_delete requirement in Filer fields
12+
513
3.2.3 (2024-09-18)
614
==================
715

README.rst

-20
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,6 @@ Documentation
4949
Please head over to the separate `documentation <https://django-filer.readthedocs.io/en/latest/index.html>`_
5050
for all the details on how to install, configure and use django-filer.
5151

52-
Upgrading
53-
=========
54-
55-
Version 3.3
56-
-----------
57-
58-
django-filer version 3 contains a change in security policy for file uploads.
59-
**By default, binary file or files of unknown type are not allowed to be uploaded.**
60-
To allow upload of binary files in your project, add
61-
62-
.. code-block:: python
63-
64-
FILER_REMOVE_FILE_VALIDATORS = [
65-
"application/octet-stream",
66-
]
67-
68-
to your project's settings. Be aware that binary files always are a security risk.
69-
See the documentation for more information on how to configure file upload validators,
70-
e.g., running files through a virus checker.
71-
7252

7353
.. |pypi| image:: https://badge.fury.io/py/django-filer.svg
7454
:target: http://badge.fury.io/py/django-filer

docs/upgrading.rst

+19
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ Usually upgrade procedure is straightforward: update the package and run migrati
77
require special attention from the developer and here we provide upgrade instructions for such cases.
88

99

10+
from 3.x to 3.3
11+
---------------
12+
13+
django-filer version 3.3 contains a change in security policy for file uploads.
14+
**By default, binary file or files of unknown type are not allowed to be uploaded.**
15+
To allow upload of binary files in your project, add
16+
17+
.. code-block:: python
18+
19+
FILER_REMOVE_FILE_VALIDATORS = [
20+
"application/octet-stream",
21+
]
22+
23+
to your project's settings. Be aware that binary files always are a security risk.
24+
See :ref:`check_virus` for more information on how to configure file upload validators,
25+
e.g., running files through a virus checker.
26+
27+
28+
1029
from 2.x to 3.0
1130
---------------
1231

docs/usage.rst

+18-7
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ Simple example ``models.py``::
4242
class Company(models.Model):
4343
name = models.CharField(max_length=255)
4444
logo = FilerImageField(null=True, blank=True,
45-
related_name="logo_company")
45+
related_name="logo_company",
46+
on_delete=models.SET_NULL)
4647
disclaimer = FilerFileField(null=True, blank=True,
47-
related_name="disclaimer_company")
48+
related_name="disclaimer_company",
49+
on_delete=models.SET_NULL)
4850

4951
multiple file fields on the same model::
5052

@@ -53,12 +55,21 @@ multiple file fields on the same model::
5355

5456
class Book(models.Model):
5557
title = models.CharField(max_length=255)
56-
cover = FilerImageField(related_name="book_covers")
57-
back = FilerImageField(related_name="book_backs")
58+
cover = FilerImageField(related_name="book_covers",
59+
on_delete=models.CASCADE)
60+
back = FilerImageField(related_name="book_backs",
61+
on_delete=models.CASCADE)
5862

59-
As with `django.db.models.ForeignKey`_ in general, you have to define a
60-
non-clashing ``related_name`` if there are multiple ``ForeignKey`` s to the
61-
same model.
63+
As with `django.db.models.ForeignKey`_ in general:
64+
65+
* You must specify an ``on_delete`` parameter to define what happens when the referenced file is deleted
66+
* You have to define a non-clashing ``related_name`` if there are multiple ``ForeignKey`` s to the same model
67+
68+
Common ``on_delete`` options:
69+
70+
* ``models.CASCADE`` - Delete the model containing the FilerFileField when the referenced file is deleted
71+
* ``models.SET_NULL`` - Set the reference to NULL when the file is deleted (requires ``null=True``)
72+
* ``models.PROTECT`` - Prevent deletion of the referenced file
6273

6374
templates
6475
.........

docs/validation.rst

+2
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ If you distinguish validation by the mime type, remember to register the
264264
validator function for all relevant mime types.
265265

266266

267+
.. _check_virus:
268+
267269
Checking uploads for viruses using ClamAV
268270
-----------------------------------------
269271

filer/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
8. Publish the release and it will automatically release to pypi
1414
"""
1515

16-
__version__ = '3.2.3'
16+
__version__ = '3.3.0'

0 commit comments

Comments
 (0)