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

Add support for related ManyToMany fields #190

Merged
merged 17 commits into from
Nov 5, 2020
Merged

Add support for related ManyToMany fields #190

merged 17 commits into from
Nov 5, 2020

Conversation

yuekui
Copy link
Contributor

@yuekui yuekui commented Oct 28, 2020

_clone_many_to_many_fields now could be used for both many to many and related fields:

class Author(CloneModel):
    books = models.ManyToManyField(Author, related_name="authors")

class Book(CloneModel):
    _clone_many_to_many_fields = ["authors"]

author = Author()
book1 = Book()

book2 = book1.make_clone()

# before this PR:
author.books.all() => [book1]

# after merging this PR:
author.books.all() => [book1, book2]

Without this PR, if you want to clone the book in above example, you have to:

book2 = book1.make_clone()
author.books.add(book2)

.github/workflows/test.yml Outdated Show resolved Hide resolved
@jackton1 jackton1 merged commit 5b3db57 into tj-django:master Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants