Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove json field compatibility, force django 3.2, refs #480 #520

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions actstream/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,3 @@ def ready(self):
DataField(blank=True, null=True).contribute_to_class(
action_class, 'data'
)

# dynamically load django_jsonfield_backport to INSTALLED_APPS
if django.VERSION < (3, 1) and 'django_jsonfield_backport' not in settings.INSTALLED_APPS:
settings.INSTALLED_APPS += ('django_jsonfield_backport', )
# reset loaded apps
apps.app_configs = OrderedDict()
# reset initialization status
apps.apps_ready = apps.models_ready = apps.loading = apps.ready = False
apps.clear_cache()
# re-initialize all apps
apps.populate(settings.INSTALLED_APPS)
38 changes: 6 additions & 32 deletions actstream/jsonfield.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,17 @@
'''

Decide on a JSONField implementation based on available packages.

These are the options:
- With recent Django >= 3.1 use Django's builtin JSONField.
- For Django versions < 3.1 we need django-jsonfield-backport
and will use its JSONField instead.

Raises an ImportError if USE_JSONFIELD is True, but none of the above
apply.

Falls back to a simple Django TextField if USE_JSONFIELD is False,
however that field will be removed by migration 0002 directly
afterwards.
django-activity-stream offered support for an optional JSON data field from 0.4.4 up until 1.4.0.
This was accomplished by overloading DataField with different model field types.
As of Django 3.2, the JSONField is supported by default.
However we need to keep this mapping to not break migrations.

'''
import django
from django.db import models
from django.core.exceptions import ImproperlyConfigured
from django.db.models import JSONField

from actstream.settings import USE_JSONFIELD


__all__ = ('DataField', )


DataField = models.TextField

if USE_JSONFIELD:
if django.VERSION >= (3, 1):
from django.db.models import JSONField
DataField = JSONField
else:
try:
from django_jsonfield_backport.models import JSONField
DataField = JSONField
except ImportError:
raise ImproperlyConfigured(
'You must install django-jsonfield-backport, '
'if you wish to use a JSONField on your actions '
'and run Django < 3.1'
)
DataField = JSONField
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Changelog
=========

Unreleased
----------

- BREAKING: Drop support for EOL versions of Django (< 3.2)
- Remove JSONField compatibility, extras and autoloading

1.4.0
------

Expand Down
13 changes: 0 additions & 13 deletions docs/data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ This uses a ``data`` JSONField on every Action where you can insert and delete v
This behavior is disabled by default but just set ``ACTSTREAM_SETTINGS['USE_JSONFIELD'] = True`` in your
settings.py to enable it.

.. note::

If you're running Django < 3.1 you must install django-jsonfield-backport or the extra ``jsonfield`` of this package.
"django_jsonfield_backport" gets dynamically added to the INSTALLED_APPS of your Django application if not yet done manually.

Please make sure to remove both the django-jsonfield-backport package and the ``django_jsonfield_backport`` INSTALLED_APPS entry (if manually added) after upgrading to Django >= 3.1

You can send the custom data as extra keyword arguments to the ``action`` signal.

.. code-block:: python
Expand Down Expand Up @@ -49,12 +42,6 @@ Adding to Existing Project

If you start out your project with ``USE_JSONFIELD=False``, dont worry you can add it afterwards.

Make sure you have the latest JSONField implementation

.. code-block::

pip install django-activity-stream[jsonfield]

Make sure ``USE_JSONFIELD`` is non-existent or set to False then do the initial migration

.. code-block:: bash
Expand Down
17 changes: 1 addition & 16 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ Add the activity urls to your urlconf

The activity urls are not required for basic usage but provide activity :ref:`feeds` and handle following, unfollowing and querying of followers.


Add extra data to actions
-------------------------

If you want to use custom data on your actions and are running Django < 3.1, then make sure you have
`django-jsonfield-backport <https://pypi.org/project/django-jsonfield-backport/>`_ installed.

.. code-block:: bash

$ pip install django-activity-stream[jsonfield]

You can learn more at :ref:`custom-data`


Supported Environments
----------------------

Expand All @@ -74,14 +60,13 @@ Make sure to pick the version of Django and django-activity-stream that supports
Python
******


* **Python 3**: 3.6 to 3.9
* **PyPy**: 3

Django
******

* **Django**: 2.2+ only
* **Django**: 3.2+ only

Databases
*********
Expand Down
3 changes: 1 addition & 2 deletions runtests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Django>=2.2.17
django-jsonfield-backport
Django>=3.2
tblib
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
license='BSD 3-Clause',
author_email='justquick@gmail.com',
url='http://github.com/justquick/django-activity-stream',
install_requires=['Django>=3.2'],
packages=['actstream',
'actstream.migrations',
'actstream.templatetags',
Expand All @@ -29,7 +30,4 @@
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Topic :: Utilities'],
extras_require={
'jsonfield': ['django-jsonfield-backport>=1.0.2,<2.0'],
},
)