django-cms / djangocms-versioning

General purpose versioning package for Django CMS 4 and above.
Other
33 stars 29 forks source link

fix: Added related_name to version content type field #274

Closed marksweb closed 1 year ago

marksweb commented 2 years ago

Description

This adds the related_name attribute to the content_type field of the Version model.

Currently the reverse lookup from a queryset will be using django's default name of version_set. That default is the reason for this change. By having this app installed, an application cannot have another model called Version with a ForeignKey to ContentType.

This is a breaking change if an application is making queries which access that reverse relationship. Currently they'd be doing something like;

page_ct = ContentType.objects.get_for_model(PageContent)
page_ct.version_set.all()
<VersionQuerySet [<Version: Version #1>, '...(remaining elements truncated)...']>

This would need to become the following with this change;

page_ct = ContentType.objects.get_for_model(PageContent)
page_ct.cms_versions.all()
<VersionQuerySet [<Version: Version #1>,  '...(remaining elements truncated)...']>

Related resources

Checklist

codecov[bot] commented 2 years ago

Codecov Report

Merging #274 (d0f3f40) into master (3e6e587) will increase coverage by 0.02%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #274      +/-   ##
==========================================
+ Coverage   90.53%   90.55%   +0.02%     
==========================================
  Files          68       69       +1     
  Lines        2324     2329       +5     
  Branches      314      314              
==========================================
+ Hits         2104     2109       +5     
  Misses        165      165              
  Partials       55       55              
Impacted Files Coverage Δ
...ning/migrations/0016_alter_version_content_type.py 100.00% <100.00%> (ø)
djangocms_versioning/models.py 95.05% <100.00%> (ø)