Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* fix django-cms#1209

Applying filer.0012_file_mime_type: psycopg2.errors.NotNullViolation: null value in column "mime_type" violates not-null constraint

* fix isort ordering

* fix isort ordering

* Bump to version 2.0.1

Co-authored-by: Jacob Rief <[email protected]>
  • Loading branch information
jrief and Jacob Rief authored Sep 4, 2020
1 parent 3ba0e04 commit 48356c4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ CHANGELOG
=========


2.0.1 (2020-09-04)
==================

* Fixed NotNullViolation: null value in column "mime_type" in migration
``filer.0012_file_mime_type.py``.


2.0.0 (2020-09-03)
==================

Expand Down
2 changes: 1 addition & 1 deletion filer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
10. twine upload dist/django-filer-{new version}.tar.gz
"""

__version__ = '2.0.0'
__version__ = '2.0.1'

default_app_config = 'filer.apps.FilerConfig'
8 changes: 5 additions & 3 deletions filer/migrations/0012_file_mime_type.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 2.1.9 on 2019-06-25 19:12
# Generated by Django 3.0.8 on 2020-09-04 10:13

import mimetypes

Expand All @@ -10,8 +10,10 @@
def guess_mimetypes(apps, schema_editor):
FileModel = apps.get_model('filer', 'File')
for file_obj in FileModel.objects.all():
file_obj.mime_type, _ = mimetypes.guess_type(file_obj.file.url)
file_obj.save(update_fields=['mime_type'])
mime_type, _ = mimetypes.guess_type(file_obj.file.url)
if mime_type:
file_obj.mime_type = mime_type
file_obj.save(update_fields=['mime_type'])


class Migration(migrations.Migration):
Expand Down

0 comments on commit 48356c4

Please sign in to comment.