RealGeeks / django-modelclone

Allows users to duplicate a model in admin
Other
58 stars 40 forks source link

attribute for initial values on clone #14

Closed jerch closed 10 years ago

jerch commented 10 years ago

It would be nice to have an attribute to set some fields to initial values upon cloning.

ghost commented 10 years ago

That's pretty much what #13 allows, but through methods rather than attributes (make it more flexible).

jerch commented 10 years ago

I get your point and just saw your commits, sorry for double posting. Actually I've patched it myself for my needs one line after your patch (the initial dictionary). How about doing both attribute and method based API enhancements? Would somewhat reflect the django way for many class attributes and their get_ method counterparts.

ghost commented 10 years ago

I don't have the last word, but I wouldn't tend to favor it. The double approach is conceptually tangled, for dubious advantages.

class MyAdmin(ClonableModelAdmin):
    def tweak_cloned_fields(self, fields):
        return dict(fields, **{
            'myfield': 'initial value',
        })

isn't so much more complex than:

class MyAdmin(ClonableModelAdmin):
    initial_clone_attrs = {
        'myfield': 'initial value',
    }
igorsobreira commented 10 years ago

Thanks for the idea @jerch, I think I'm with @hsoft on this one. I rather have only one way to do the same thing.

I'll close this issue in favor of #13 . Thanks!