On Wed, Jan 04, 2017 at 06:38:54PM -0200, Guilherme Leal wrote:
> Is there a way to populate Django model cache on the fly?
> I was thinking about saving the model definition on some backend (database
> for instance) and loading as needed. This way we can basically build a
> custom admin interface for the model definitions, and load the models
> (through "type()" or something similar) into the cache "on the fly".
> 
> Guilherme Leal

Hi Guilherme,

I kinda got lost deeper in the reply chain in this thread, but
regarding the original question, have you had a look at
https://djangopackages.org/grids/g/dynamic-models/ ? django-mutant, in
particular, seems to be quite close to what you're asking for. Even if
it's not a direct solution for you, you might be able to take a lot of
inspiration from there.

However, keep in mind that any kind of dynamic runtime model
registration involves heavy usage of Django internals, which means it
will be fragile, and likely to break with each new minor release of
Django. Also, there are many parts of the ORM that kind of just assume
that models are static throughout the lifetime of a Python process,
with all kinds of field caching, but also things like the way
relationship fields are resolved on startup. So even if you put
something together that appears to kind of work, expect there to be a
lot of corner cases and things that outright won't work.

Good luck,

Michal

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/20170105200033.GH1628%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: Digital signature

Reply via email to