Skip to content

Commit c890b70

Browse files
Fix migrate to bigautofield (#411)
* Fixes #410 * Added #411 to CHANGELOG * Delete unnecessary operations in 0011 Co-authored-by: Andrew Chen Wang <[email protected]>
1 parent c775d29 commit c890b70

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
## Unreleased
22

3-
## Version 4.7
3+
## Version 4.7.1
4+
5+
* Fixed user-generated migration file bug in token_blacklist ([#410]((https://github.com/jazzband/django-rest-framework-simplejwt/pull/411)))
6+
7+
## Version 4.7.0
48

59
* Added support for Django 3.2 and drop Django 3.0 ([#404](https://github.com/jazzband/django-rest-framework-simplejwt/pull/404))
610
* Added Italian translations ([#342](https://github.com/jazzband/django-rest-framework-simplejwt/pull/342))

rest_framework_simplejwt/token_blacklist/apps.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
class TokenBlacklistConfig(AppConfig):
66
name = 'rest_framework_simplejwt.token_blacklist'
77
verbose_name = _('Token Blacklist')
8+
default_auto_field = 'django.db.models.BigAutoField'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generated by Django 3.2.3 on 2021-05-27 17:46
2+
3+
import os, fnmatch
4+
from pathlib import Path
5+
6+
from django.db import migrations, models
7+
8+
parent_dir = Path(__file__).resolve(strict=True).parent
9+
10+
11+
class Migration(migrations.Migration):
12+
13+
dependencies = [
14+
('token_blacklist', '0008_migrate_to_bigautofield'),
15+
]
16+
17+
operations = [
18+
migrations.AlterField(
19+
model_name='blacklistedtoken',
20+
name='id',
21+
field=models.BigAutoField(primary_key=True, serialize=False),
22+
),
23+
migrations.AlterField(
24+
model_name='outstandingtoken',
25+
name='id',
26+
field=models.BigAutoField(primary_key=True, serialize=False),
27+
),
28+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import fnmatch
2+
import os
3+
from pathlib import Path
4+
5+
from django.db import migrations, models
6+
7+
parent_dir = Path(__file__).resolve(strict=True).parent
8+
9+
10+
class Migration(migrations.Migration):
11+
12+
def __init__(self, *args, **kwargs):
13+
super().__init__(*args, **kwargs)
14+
self.dependencies = [
15+
('token_blacklist', '0010_fix_migrate_to_bigautofield')
16+
]
17+
_m = sorted(fnmatch.filter(os.listdir(parent_dir), "000*.py"))
18+
if len(_m) == 9:
19+
self.dependencies.insert(0, ('token_blacklist', os.path.splitext(_m[8])[0]))
20+
21+
operations = [
22+
]

rest_framework_simplejwt/token_blacklist/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
class OutstandingToken(models.Model):
6-
id = models.BigAutoField(primary_key=True)
6+
id = models.BigAutoField(primary_key=True, serialize=False)
77
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True, blank=True)
88

99
jti = models.CharField(unique=True, max_length=255)
@@ -29,7 +29,7 @@ def __str__(self):
2929

3030

3131
class BlacklistedToken(models.Model):
32-
id = models.BigAutoField(primary_key=True)
32+
id = models.BigAutoField(primary_key=True, serialize=False)
3333
token = models.OneToOneField(OutstandingToken, on_delete=models.CASCADE)
3434

3535
blacklisted_at = models.DateTimeField(auto_now_add=True)

0 commit comments

Comments
 (0)