Skip to content

Fix migrate to bigautofield #411

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

Merged
merged 5 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## Unreleased

## Version 4.7
## Version 4.7.1

* Fixed user-generated migration file bug in token_blacklist ([#410]((https://github.com/jazzband/django-rest-framework-simplejwt/pull/411)))

## Version 4.7.0

* Added support for Django 3.2 and drop Django 3.0 ([#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))
Expand Down
1 change: 1 addition & 0 deletions rest_framework_simplejwt/token_blacklist/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
class TokenBlacklistConfig(AppConfig):
name = 'rest_framework_simplejwt.token_blacklist'
verbose_name = _('Token Blacklist')
default_auto_field = 'django.db.models.BigAutoField'
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.2.3 on 2021-05-27 17:46

import os, fnmatch
from pathlib import Path

from django.db import migrations, models

parent_dir = Path(__file__).resolve(strict=True).parent


class Migration(migrations.Migration):

dependencies = [
('token_blacklist', '0008_migrate_to_bigautofield'),
]

operations = [
migrations.AlterField(
model_name='blacklistedtoken',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='outstandingtoken',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import fnmatch
import os
from pathlib import Path

from django.db import migrations, models

parent_dir = Path(__file__).resolve(strict=True).parent


class Migration(migrations.Migration):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.dependencies = [
('token_blacklist', '0010_fix_migrate_to_bigautofield')
]
_m = sorted(fnmatch.filter(os.listdir(parent_dir), "000*.py"))
if len(_m) == 9:
self.dependencies.insert(0, ('token_blacklist', os.path.splitext(_m[8])[0]))

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'),
),
]
4 changes: 2 additions & 2 deletions rest_framework_simplejwt/token_blacklist/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class OutstandingToken(models.Model):
id = models.BigAutoField(primary_key=True)
id = models.BigAutoField(primary_key=True, serialize=False)
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 @@ -29,7 +29,7 @@ def __str__(self):


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

blacklisted_at = models.DateTimeField(auto_now_add=True)
Expand Down