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[1]. Archiving becomes 
really 
easy that way.


-- 
Melvyn Sopacua

--------
[1] 
https://docs.djangoproject.com/en/2.0/topics/db/multi-db/#selecting-a-database-for-save

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2130083.vAuLGcjiVo%40fritzbook.
For more options, visit https://groups.google.com/d/optout.

Reply via email to