On vrijdag 29 juni 2018 09:44:40 CEST Mickael Barbo wrote:
> I try to create a way to archive (copy) the same object instance on an
> other DataBase.
>
> I followed this advice : # https://stackoverflow.com/
> questions/21699707/python-how-to-copy-all-attibutes-from-
> base-class-to-derived-one
That advice is for normal python classes. Django models have some restrictions, one being that fields are special attributes. Messing with a model's __init__() is not something you normally do as a model's class creation is highly customized.
If you're really using 2 different databases, a model's save() operation supports a `using` keyword that allows you to select the database connection. Archiving becomes really easy that way.
--
Melvyn Sopacua
No comments:
Post a Comment