Skip to content

Commit

Permalink
fix: Added related_name to version content type field (#274)
Browse files Browse the repository at this point in the history
* Add a `related_name` to the version model content_type foreign key. [fix #273]

* Updated changelog

---------

Co-authored-by: Fabian Braun <fsbraun@gmx.de>
  • Loading branch information
marksweb and fsbraun authored May 10, 2023
1 parent 3e6e587 commit 2ce8647
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog

Unreleased
==========
* fix: Added ``related_name`` attribute to the ``content_type`` foreign key of the ``Version`` model.
* fix: burger menu adjusts to the design of django cms core dropdown
* fix: bug that showed an archived version as unpublished in some cases in the state indicator
* add: Dutch and French translations thanks to Stefan van den Eertwegh and François Palmierso
Expand Down
20 changes: 20 additions & 0 deletions djangocms_versioning/migrations/0016_alter_version_content_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.2.13 on 2022-05-20 21:11

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('djangocms_versioning', '0015_version_modified'),
]

operations = [
migrations.AlterField(
model_name='version',
name='content_type',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='cms_versions', to='contenttypes.contenttype'),
),
]
6 changes: 5 additions & 1 deletion djangocms_versioning/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ class Version(models.Model):
settings.AUTH_USER_MODEL, on_delete=models.PROTECT, verbose_name=_("author")
)
number = models.CharField(max_length=11)
content_type = models.ForeignKey(ContentType, on_delete=models.PROTECT)
content_type = models.ForeignKey(
ContentType,
on_delete=models.PROTECT,
related_name="cms_versions"
)
object_id = models.PositiveIntegerField()
content = GenericForeignKey("content_type", "object_id")
state = FSMField(
Expand Down

0 comments on commit 2ce8647

Please sign in to comment.