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 #189

Closed
wants to merge 3 commits into from
Closed

Add support for related ManyToMany fields #189

wants to merge 3 commits into from

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):
    first_name = models.CharField(max_length=200, unique=True)
    last_name = models.CharField(max_length=200)

class Book(CloneModel):
    name = models.CharField(max_length=2000)
    authors = models.ManyToManyField(Author, related_name="books")

    _clone_many_to_many_fields = ["authors"]

or

class Author(CloneModel):
    first_name = models.CharField(max_length=200, unique=True)
    last_name = models.CharField(max_length=200)

    _clone_many_to_many_fields = ["books"]

class Book(CloneModel):
    name = models.CharField(max_length=2000)
    authors = models.ManyToManyField(Author, related_name="books")

@yuekui yuekui closed this Oct 28, 2020
@jackton1
Copy link
Member

@yuekui Can you add a description of why we need this change . I'm curious to know the use case. Thanks

@yuekui
Copy link
Contributor Author

yuekui commented Oct 30, 2020

@yuekui Can you add a description of why we need this change . I'm curious to know the use case. Thanks

Hi @jackton1 thanks for you attention, I just added a simple example in #190 , I hope it could help

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.

2 participants