Django 2.2.11

We got ImportErrors on 'six' when creating a django application after having installed haystack:

File "/home/nina/.local/lib/python3.7/site-packages/haystack/utils/__init__.py", line 9, in <module>
    from django.utils import six
ImportError: cannot import name 'six' from 'django.utils' (/home/nina/.local/lib/python3.7/site-packages/django/utils/__init__.py)

The Django 3.0.0 release notes specify that certain private Python 2 compatibility APIs were removed. Among those was django.utils.six. Apparently haystack uses six. We could either downgrade Django version to 2.2.11, or wait until haystack fixes the issue: Issue #1697, https://github.com/django-haystack/django-haystack/pull/1710:Fix for issue #1697 Django 3.0 #1710: “I’m thinking we merge this now and finish removing six in another branch”.

We decided to shred all we had, downgrade, uninstall the lot and installed 2.2.11 with:

(search) [user]@[machine]:~/Development$ pip3 install django==2.2.11
Downloading https://files.pythonhosted.org/packages/be/76/7ccbcf52366590ca76997ce7860308b257b79962a4e4fada5353f72d7be5/Django-2.2.11-py3-none-any.whl (7.5MB)
    100% |████████████████████████████████| 7.5MB 193kB/s 
Requirement already satisfied: pytz in ./.local/lib/python3.7/site-packages (from django==2.2.11) (2019.3)
Requirement already satisfied: sqlparse in ./.local/lib/python3.7/site-packages (from django==2.2.11) (0.3.1)
Installing collected packages: django
Successfully installed django-2.2.11
(search) [user]@[machine]:~/Development$ django-admin startproject search

This creates a basic django structure:

(search) [user]@[machine]:~/Development$ tree
.
└── search
    ├── manage.py
    └── search
        ├── __init__.py
        ├── settings.py
        ├── urls.py
        └── wsgi.py

2 directories, 5 files

Test it works (there are no database tables yet, so expect warnings …

(search) [user]@[machine]:~/Development/search$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

March 21, 2020 - 16:29:58
Django version 2.2.11, using settings 'search.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Create SQLite database (db.sqlite3) and the tables for authentication:

(search) [user]@[machine]:~/Development/search$ python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying sessions.0001_initial... OK

Test again:

(search) [user]@[machine]:~/Development/search$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
March 21, 2020 - 16:36:05
Django version 2.2.11, using settings 'search.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
  • Last modified: 2020/03/25 17:33