Skip to content
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

fix: Added related_name to version content type field #274

Merged
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