Skip to content

Commit

Permalink
Fixed #784 -- Added migrations autodetected by Django 4.0 (#785)
Browse files Browse the repository at this point in the history
* Fixed #784 -- Added migrations autodetected by Django 4.0

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixed import sorting

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
bmispelon and pre-commit-ci[bot] committed Jan 7, 2022
1 parent 5556944 commit 9d9ca4b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This migration has no effect in practice. It exists to stop
# Django from autodetecting migrations in taggit when users
# update to Django 4.0.
# See https://docs.djangoproject.com/en/stable/releases/4.0/#migrations-autodetector-changes
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("contenttypes", "0002_remove_content_type_name"),
("taggit", "0003_taggeditem_add_unique_index"),
]

operations = [
migrations.AlterField(
model_name="taggeditem",
name="content_type",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="%(app_label)s_%(class)s_tagged_items",
to="contenttypes.contenttype",
verbose_name="content type",
),
),
migrations.AlterField(
model_name="taggeditem",
name="tag",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="%(app_label)s_%(class)s_items",
to="taggit.tag",
),
),
]
9 changes: 9 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from io import StringIO
from unittest import mock

from django.contrib.contenttypes.models import ContentType
from django.core import serializers
from django.core.exceptions import ValidationError
from django.core.management import call_command
from django.db import IntegrityError, connection, models
from django.test import RequestFactory, SimpleTestCase, TestCase
from django.test.utils import override_settings
Expand Down Expand Up @@ -1274,3 +1276,10 @@ def test_added_tags_are_returned_ordered(self):
["blue", "green", "orange", "red", "yellow"],
list(obj.tags.values_list("name", flat=True)),
)


class PendingMigrationsTests(TestCase):
def test_taggit_has_no_pending_migrations(self):
out = StringIO()
call_command("makemigrations", "taggit", dry_run=True, stdout=out)
self.assertEqual(out.getvalue().strip(), "No changes detected in app 'taggit'")

0 comments on commit 9d9ca4b

Please sign in to comment.