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

Save_as does not handle manytomany field gracefully #6

Open
karthikbgl opened this issue Dec 6, 2013 · 3 comments
Open

Save_as does not handle manytomany field gracefully #6

karthikbgl opened this issue Dec 6, 2013 · 3 comments

Comments

@karthikbgl
Copy link

Lets say there is a validation error on the object to be cloned, if the object has any many to many fields, it loses the reference to those.

@igorsobreira
Copy link
Contributor

Hi @karthikbgl,

I couldn't reproduce this bug. I added a couple tests for m2m fields, please see afaae0d. Did I cover your bug or is it another scenario?

@karthikbgl
Copy link
Author

Hi @igorsobreira

Thank you for the quick response. My scenario is:

class ModelAConfigInline():
    model = ModelAConfig

class ModelAAdmin(ClonableModelAdmin):
    inlines = [ModelAConfigInline]

and the model relationships:

class ModelAConfig(models.Model):
    premiums = models.ForeignKey(PremiumSet, null=True, blank=True)
    campaign = models.ForeignKey(ModelA)
    #Basically, the reverse foreign key relationship. 

My apologies for not giving enough details upfront.

@igorsobreira
Copy link
Contributor

I'm a bit confused. You mentioned Many to Many relationship in the issue but this code sample has a One to Many.

When you are editing a ModelA object and click Clone, all django-modelclone does is give you a form pre-filled so you can create a new ModelA; and if the original ModelA had inlines, that is ModelAConfigs referencing it, your clone form will have pre-filled inline forms to create new ModelAConfig objects, that will reference the new ModelA.

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

No branches or pull requests

2 participants