1

I've recently tried to implement Django-Bleach into my project, but I'm having an issue with an import library. I am currently running Python 3.6.2 and Django 1.11. When I try to define a django_bleach form in my forms.py, with the following statement:

from django_bleach.forms import BleachField

I am receiving the following error:

ModuleNotFoundError: No module named 'django.utils.importlib'

I spent the better part of this afternoon researching this error and I have come to understand that the django.utils.importlib statement was deprecated in 1.9. However, I can't seem to determine a workaround for this problem. I did try the suggestion outlined in this issue but it didn't seem to make a difference. I still receive the error. Cannot import importlib

I'm also wondering if I should be using bleach instead of django-bleach as django-bleach doesn't seem to be updated since 2014. Thanks in advance for your suggestions and help.

Steve Smith
  • 1,019
  • 3
  • 16
  • 38
  • please you can check this, I think it would help : https://stackoverflow.com/a/32763639/9970044 – Bilal Mahmud Jun 20 '18 at 23:10
  • Bilal Mahmud Thanks for the suggestion. I saw it as well but to no aval. Where would the code that was outlined at the bottom of the issue...try: # Django versions >= 1.9 from django.utils.module_loading import import_module except ImportError: # Django versions < 1.9 from django.utils.importlib import import_module Be placed? I put it in my forms.py file and it still did not help. I also tried to add from importlib import import_module to my forms.py file and that did not help either. – Steve Smith Jun 20 '18 at 23:16

2 Answers2

2

Package you are trying to use doesen't seem to be maintained.

Error you are facing is related to the forms.py line 7

from django.utils.importlib import import_module

If you are really into the following wrapper package you could fork/fix it and install your forked version instead

iklinac
  • 14,944
  • 4
  • 28
  • 30
1

Ultimately wound up incorporating just bleach into my django installation. It appears django-bleach is no longer supported for Python 3. Using Bleach and incorporating it according to the documentation allowed me resolve this issue.

Steve Smith
  • 1,019
  • 3
  • 16
  • 38
  • 4
    `django-bleach` has since been updated with support for python 3 and django 2.x - https://pypi.org/project/django-bleach/ – markwalker_ Feb 04 '19 at 09:55