Skip to content

Commit

Permalink
Add migration file for Django3.2 BigAutoField update. (#404)
Browse files Browse the repository at this point in the history
Fixes #395 

* Add Django 3.2 in test.yml of github workflows
* Add explicit id fields for BigAutoField in balcklist app models
* Add Django 3.2 env to tox.ini
* Add support for Django 3.2 + Update Links
* Due to migration due Jazzband, links in the CHANGELOG for the proper user/organization needed to be updated.

Co-authored-by: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com>
  • Loading branch information
Alig1493 and Andrew-Chen-Wang committed May 15, 2021
1 parent aaebe1a commit 9b4f06a
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
max-parallel: 5
matrix:
python-version: ['3.7', '3.8', '3.9']
django-version: ['2.2', '3.0', '3.1', 'main']
django-version: ['2.2', '3.0', '3.1', '3.2', 'main']
drf-version: ['3.10', '3.11', '3.12']
exclude:
- python-version: '3.7'
Expand Down
52 changes: 27 additions & 25 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
## Version 4.7
## Version 4.7.0

* Added Italian translations ([#342](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/342))
* Added support for Django 3.2 ([#404](https://github.com/jazzband/django-rest-framework-simplejwt/pull/404))
* Added Italian translations ([#342](https://github.com/jazzband/django-rest-framework-simplejwt/pull/342))
* Fixed DRF app registry bug, specifically `django.core.exceptions.AppRegistryNotReady`
([#331](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/331))
* Fixed support for PyJWT>=2.0.0 ([#376](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/376))
([#331](https://github.com/jazzband/django-rest-framework-simplejwt/pull/331))
* Fixed support for PyJWT>=2.0.0 ([#376](https://github.com/jazzband/django-rest-framework-simplejwt/pull/376))
* Migrated blacklist app models to use BigAutoField IDs for Django>=3.2. ([#404](https://github.com/jazzband/django-rest-framework-simplejwt/pull/404))

## Version 4.6

* Added support for PyJWT>=2.0.0 ([#329](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/329))
* Restored Python 3.7 support ([#332](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/332))
* Added Indonesian translations ([#316](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/316))
* Fixed Django 4.0 re_path deprecation ([#280](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/280))
* Added support for PyJWT>=2.0.0 ([#329](https://github.com/jazzband/django-rest-framework-simplejwt/pull/329))
* Restored Python 3.7 support ([#332](https://github.com/jazzband/django-rest-framework-simplejwt/pull/332))
* Added Indonesian translations ([#316](https://github.com/jazzband/django-rest-framework-simplejwt/pull/316))
* Fixed Django 4.0 re_path deprecation ([#280](https://github.com/jazzband/django-rest-framework-simplejwt/pull/280))

## Version 4.5

* Added `AUTH_HEADER_NAME` to settings ([#309](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/309))
* Added `USER_AUTHENTICATION_RULE` to settings ([#279](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/279))
* Added `UPDATE_LAST_LOGIN` to settings ([#238](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/238))
* Fixed packaging of locale folder for installation ([#117](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/117))
* Allowed TokenUser to be configurable ([#172](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/172))
* Added `AUTH_HEADER_NAME` to settings ([#309](https://github.com/jazzband/django-rest-framework-simplejwt/pull/309))
* Added `USER_AUTHENTICATION_RULE` to settings ([#279](https://github.com/jazzband/django-rest-framework-simplejwt/pull/279))
* Added `UPDATE_LAST_LOGIN` to settings ([#238](https://github.com/jazzband/django-rest-framework-simplejwt/pull/238))
* Fixed packaging of locale folder for installation ([#117](https://github.com/jazzband/django-rest-framework-simplejwt/pull/117))
* Allowed TokenUser to be configurable ([#172](https://github.com/jazzband/django-rest-framework-simplejwt/pull/172))
* Dropped Python 3.7 and below (restored Python 3.7 but not 3.6 in next version)
* Improved error message if cryptography isn't installed
when developer tries to use a certain algorithm that needs the package
([#285](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/285))
* Fixed Django 4.0 ugettext_lazy deprecation warnings ([#186](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/186))
* Remove upper bound of Python version ([#225](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/225))
* Added DRF 3.11 support ([#230](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/230))
([#285](https://github.com/jazzband/django-rest-framework-simplejwt/pull/285))
* Fixed Django 4.0 ugettext_lazy deprecation warnings ([#186](https://github.com/jazzband/django-rest-framework-simplejwt/pull/186))
* Remove upper bound of Python version ([#225](https://github.com/jazzband/django-rest-framework-simplejwt/pull/225))
* Added DRF 3.11 support ([#230](https://github.com/jazzband/django-rest-framework-simplejwt/pull/230))

Translations:
* Added French translations ([#314](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/314))
* Added Spanish translations ([#294](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/294))
* Added Argentinian Spanish translations ([#244](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/244))
* Added Persian translations ([#220](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/220))
* Added German translations ([#198](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/198))
* Added Czech translations ([#188](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/188))
* Added Polish translations ([#166](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/166))
* Fixed incorrect language encoding from de_CH to es_CL ([#299](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/299))
* Added French translations ([#314](https://github.com/jazzband/django-rest-framework-simplejwt/pull/314))
* Added Spanish translations ([#294](https://github.com/jazzband/django-rest-framework-simplejwt/pull/294))
* Added Argentinian Spanish translations ([#244](https://github.com/jazzband/django-rest-framework-simplejwt/pull/244))
* Added Persian translations ([#220](https://github.com/jazzband/django-rest-framework-simplejwt/pull/220))
* Added German translations ([#198](https://github.com/jazzband/django-rest-framework-simplejwt/pull/198))
* Added Czech translations ([#188](https://github.com/jazzband/django-rest-framework-simplejwt/pull/188))
* Added Polish translations ([#166](https://github.com/jazzband/django-rest-framework-simplejwt/pull/166))
* Fixed incorrect language encoding from de_CH to es_CL ([#299](https://github.com/jazzband/django-rest-framework-simplejwt/pull/299))

## Version 4.4

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('token_blacklist', '0007_auto_20171017_2214'),
]

operations = [
migrations.AlterField(
model_name='blacklistedtoken',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='outstandingtoken',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
]
2 changes: 2 additions & 0 deletions rest_framework_simplejwt/token_blacklist/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


class OutstandingToken(models.Model):
id = models.BigAutoField(primary_key=True)
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True, blank=True)

jti = models.CharField(unique=True, max_length=255)
Expand All @@ -28,6 +29,7 @@ def __str__(self):


class BlacklistedToken(models.Model):
id = models.BigAutoField(primary_key=True)
token = models.OneToOneField(OutstandingToken, on_delete=models.CASCADE)

blacklisted_at = models.DateTimeField(auto_now_add=True)
Expand Down
15 changes: 15 additions & 0 deletions tests/test_token_blacklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.contrib.auth.models import User
from django.core.management import call_command
from django.db.models import BigAutoField
from django.test import TestCase

from rest_framework_simplejwt.exceptions import TokenError
Expand Down Expand Up @@ -190,3 +191,17 @@ def test_jti_field_should_contain_uuid_hex_strings(self):
actual_hexes = [i.jti_hex for i in OutstandingToken.objects.all()]

self.assertEqual(actual_hexes, self.expected_hexes)


class TestBigAutoFieldIDMigration(MigrationTestCase):
migrate_from = ('token_blacklist', '0007_auto_20171017_2214')
migrate_to = ('token_blacklist', '0008_migrate_to_bigautofield')

def test_outstandingtoken_id_field_is_biagauto_field(self):
OutstandingToken = self.apps.get_model('token_blacklist', 'OutstandingToken')
assert isinstance(OutstandingToken._meta.get_field('id'), BigAutoField)

def test_blacklistedtoken_id_field_is_biagauto_field(self):
BlacklistedToken = self.apps.get_model('token_blacklist', 'BlacklistedToken')
assert isinstance(BlacklistedToken._meta.get_field('id'), BigAutoField)

4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist=
py{37,38,39}-dj{22,30}-drf310-tests
py{37,38,39}-dj{22,30,31}-drf{311,312}-tests
py{37,38,39}-dj{22,30,31,32}-drf{311,312}-tests
py39-djmain-drf312-tests
docs
lint
Expand All @@ -17,6 +17,7 @@ DJANGO=
2.2: dj22
3.0: dj30
3.1: dj31
3.2: dj32
main: djmain
DRF=
3.10: drf310
Expand All @@ -35,6 +36,7 @@ deps=
dj22: Django>=2.2,<2.3
dj30: Django>=3.0,<3.1
dj31: Django>=3.1,<3.2
dj32: Django>=3.2,<3.3
drf310: djangorestframework>=3.10,<3.11
drf311: djangorestframework>=3.11,<3.12
drf312: djangorestframework>=3.12,<3.13
Expand Down

0 comments on commit 9b4f06a

Please sign in to comment.