Skip to content

Releases: wq/django-natural-keys

v2.1.1

27 Mar 14:45
Compare
Choose a tag to compare

natural-keys 2.1.1 brings a couple minor improvements by @sheppard.

  • Confirm support for Python 3.12 and Django 5.0 (95660c3)
  • Don't build nested keys for M2M relationships (1fd3d6b)

natural-keys 2.1.0

16 Jun 14:20
Compare
Choose a tag to compare

natural-keys 2.1.0 improves natural key detection and handling, particularly for null relationships. Otherwise, this release is essentially compatible with natural-keys 2.0.0, but note the type change for the output of natural_key().

All changes by @sheppard.

  • Don't crash when serializing models with null foreign keys (#18, bbe6f64)
  • Return a Python tuple instead of a list from natural_key() and get_natural_key_fields(). The documentation already assumes tuple output, as that is a more correct type for these values. This change should not affect normal usage. (bbe6f64)
  • Don't automatically build nested natural key serializers for reverse relationships (142ffd0)
  • Allow overriding natural key detection via NaturalKeyModelSerializer.is_natural_key_model() (86958a7)
  • Update code style, switch to pyproject.toml, and test with latest Python and Django versions (309fcee, 4e4fa11)

natural-keys 2.0.0

24 Aug 12:25
58e9a15
Compare
Choose a tag to compare

natural-keys 2.0.0 improves support for Django 3.2 and drops support for Python 2.7.

New Features

  • Ignore BigAutoField in addition to AutoField when detecting single unique key (#16, #17 via @marcosox)
  • Detect UniqueConstraint in addition to unique_together, and make UniqueConstraint the recommended option (#14)
  • Support using natural_keys.models without installing Django REST Framework (#15)
  • Move to Github Actions

Breaking Changes

  • This release removes support for EOL versions of Python and Django, including Python 2.7 and Django 2.1.

natural-keys 1.6.0

10 Jan 07:19
Compare
Choose a tag to compare

natural-keys 1.6.0 confirms compatibility with Python 3.8, Django 3.0, and Django REST Framework 3.11. Other than a minor fix for DRF 3.11, the functionality remains the same.

natural-keys 1.5.1

02 Sep 01:40
Compare
Choose a tag to compare

natural-keys 1.5.1 adds a defaults keyword argument to get_or_create_by_natural_key() and find(). This is based on the similar argument for get_or_create(), and is important when you have required fields on a model that are not part of a natural key.

While get_or_create() accepts keyword arguments, get_or_create_by_natural_key() and find() use positional arguments for the natural key fields (like get_by_natural_key()), with defaults being the only keyword argument.

instance, is_new = Event.objects.get_or_create_by_natural_key(
    'ABC123', date(2016, 1, 1),
    defaults={
        "name": "Example Event",
        "public": True,
    }
)

natural-keys 1.5.0

01 Mar 04:44
542d905
Compare
Choose a tag to compare

natural-keys 1.5.0 ensures that natural_key_slug can only be passed as a kwarg to NaturalKeyQuerySet.filter(). The implementation in 1.4.0 was breaking the common use case of passing in a Q object as the first argument (#8). This was fixed thanks to contributions from @arvindch (#9), @marcosox (#10), and @github-account-because-they-want-it (#11).

Note: If you were relying on this (unintended) feature, you will need to update any instances of e.g. MyModel.objects.get("abc-123") with one of the following:

  • MyModel.objects.get(natural_key_slug="abc-123")
  • MyModel.objects.get_by_natural_key("abc", "123")

Other changes in this version:

  • Option to specify natural key fields via _natural_key instead of Meta.unique_together[0] (#9 via @arvindch)
  • Export NaturalKeyModelManager & NaturalKeyQuerySet in top level module (#9)
  • Update test matrix to add Python 3.7 and Django 2.1. Django 1.8 LTS is still included for now though it is technically deprecated.
  • Integrate setuptools_scm; use markdown for PyPI readme; clarify (non-)uses of NaturalKeySerializer,

natural-keys 1.4.0

12 Apr 16:39
Compare
Choose a tag to compare

natural-keys 1.3.0

06 Apr 15:15
Compare
Choose a tag to compare
  • Add support for Django 2.0 (#5 via @ofalk).
  • Drop Django 1.9 and 1.10 from test matrix. Django 1.8 LTS is still included for now.

natural-keys 1.2.1

13 Sep 14:24
Compare
Choose a tag to compare

natural-keys 1.2.1 brings a couple of improvements to NaturalKeySerializer:

  • More descriptive error message if include_fields is incorrect (#2 via @tomaszn)
  • Support for models with single unique field instead of unique_together (60b3327)

natural-keys 1.2.0

02 May 16:31
Compare
Choose a tag to compare

natural-keys 1.2.0 makes it possible to use a single unique field as a natural key (without having to specifiy unique_together). Thanks to @tomaszn for this patch (#1).