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

Conversation

marksweb
Copy link
Member

@marksweb marksweb commented May 20, 2022

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

  • I have opened this pull request against master
  • I have added or modified the tests when changing logic
  • I have followed the conventional commits guidelines to add meaningful information into the changelog
  • I have read the contribution guidelines and I have joined #workgroup-pr-review on
    Slack to find a “pr review buddy” who is going to review my pull request.

@marksweb marksweb requested a review from Aiky30 May 20, 2022 21:58
@codecov
Copy link

codecov bot commented May 20, 2022

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%> (ø)

@marksweb marksweb force-pushed the fix/273/version-content-type-related-name branch from 1efebe7 to f73ed8b Compare May 20, 2022 21:59
@fsbraun fsbraun merged commit 2ce8647 into django-cms:master May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants