Persisting external classes in Django

I am working on a Django application that uses the SimpleGmail package to fetch mails from a Gmail inbox and I need to persist them. Normally I'd have written a model for the class, but given it's an external class, I can't figure out how to cleanly persist it.

I have come across solutions such as making it an attribute of a new model that is persisted or multiple inheritance of the desired class, but none of these seem correct to me.

How do I properly register an external class as a model for Django's persistence?

It is too long to comment. So I will try to write an answer.

One way is is to create a model class with properties which can be mapped from external class with all properties.

Another way would be just import external class in your application and create an instance of this external class. I am sorry, I am not Python guy, so code implementation would not be provided.

Back to Top