@Vijay Khemlani - No ORM unless you implement it - No DB integrity checks That was exacly the points i'm willing to avoid. Had any problems with the metaclass approach? Why did you chose the "virtual model" concept?
2017-01-05 16:12 GMT-02:00 Vijay Khemlani <[email protected]>: > I had to implement dynamic models for our project. > > In the end we represented them in four django models, two for the > "virtual models" and its fields and two for the actual data > > We used the django model system for these four base classes, but the > "virtual models" on top of them were custom (so no django orm, all > queries included joins, etc etc) > > Our solution to that was to index the important data in ElasticSearch > and execute the queries there > > Pros: > - Completely dynamic > - Does not depend on metaprogramming or Django's models > - Querying via ElasticSearch is not so bad and is quite fast > > Cons: > - Quite slow when you need to update data in the database > - No ORM unless you implement it > - You have to be careful keeping the index entries updated when needed > - Limited to basic data types (int, char, decimal, date, file) > - No DB integrity checks > > On 1/5/17, Guilherme Leal <[email protected]> wrote: > > I know metaclasses, and i know that the django models uses some "meta > class > > magic" to register the models on the model cache. > > I gess i need to test the implication of refreshing the model cache on > the > > fly, since it doesn't have a "natural" way to refresh itself. > > > > 2017-01-05 14:05 GMT-02:00 Avraham Serour <[email protected]>: > > > >> you should read about metaclasses, basically it enables you to build > >> class > >> definitions in runtime. > >> > >> http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python > >> > >> > >> On Thu, Jan 5, 2017 at 6:02 PM, Guilherme Leal <[email protected]> > >> wrote: > >> > >>> The "migrations on the fly" thing dont get to be a problem (since I > gess > >>> we could call the migrations api to generate the migration). > >>> My concenrs would be contructing and refreshing the model cache (I say > >>> the "model cache" like the list accessed through > >>> django.apps.get_models() > >>> ), and the OBVIOUS performance issues that could be generated. > >>> > >>> Anyway, EVEN if it turns out to be impratical to production, i want to > >>> build it as a proof of concept, and see where it can go, so any help or > >>> ideias would be apreciated! > >>> > >>> 2017-01-05 13:52 GMT-02:00 Beautifulloop <[email protected]>: > >>> > >>>> I think you just need to define a generic model. I dont see how what > >>>> you > >>>> are asking is feasible since it would require that (on the fly that > >>>> migrations are made). You can write a generic model where the types > can > >>>> be > >>>> represented by a field name. > >>>> > >>>> > >>>> On Thursday, 5 January 2017 17:33:07 UTC+2, Guilherme Leal wrote: > >>>>> > >>>>> My idea was to build an user interface for the model definition, so > >>>>> the > >>>>> developer (or in this case, the user) could define the model using a > >>>>> register form. > >>>>> > >>>>> Like a user interface to define the model layer, I gess. > >>>>> > >>>>> 2017-01-05 12:34 GMT-02:00 Avraham Serour <[email protected]>: > >>>>> > >>>>>> I guess you could play with metaclasses and generate the class > >>>>>> definition on runtime using information from the database > >>>>>> > >>>>>> But why? You can save the model definition on files, why saving them > >>>>>> to database and complicate your life? > >>>>>> > >>>>>> On Wed, Jan 4, 2017 at 10:38 PM, Guilherme Leal <[email protected]> > >>>>>> 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 > >>>>>>> > >>>>>>> -- > >>>>>>> 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/CAOs3Lp7_R4RK > >>>>>>> %3DVconoQ1W6rzK8xYaiVJX-FHtyZ3Cxg4MmbOow%40mail.gmail.com > >>>>>>> <https://groups.google.com/d/msgid/django-users/CAOs3Lp7_ > R4RK%3DVconoQ1W6rzK8xYaiVJX-FHtyZ3Cxg4MmbOow%40mail.gmail. > com?utm_medium=email&utm_source=footer> > >>>>>>> . > >>>>>>> For more options, visit https://groups.google.com/d/optout. > >>>>>>> > >>>>>> > >>>>>> -- > >>>>>> 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/CAFWa6t%2B5DO > >>>>>> 5u8p5fRrGAGkW1KYR2DZxc_wtkNQG7bX3u6v7JuA%40mail.gmail.com > >>>>>> <https://groups.google.com/d/msgid/django-users/CAFWa6t% > 2B5DO5u8p5fRrGAGkW1KYR2DZxc_wtkNQG7bX3u6v7JuA%40mail. > gmail.com?utm_medium=email&utm_source=footer> > >>>>>> . > >>>>>> For more options, visit https://groups.google.com/d/optout. > >>>>>> > >>>>> > >>>>> -- > >>>> 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/ms > >>>> gid/django-users/e00f8c04-8c97-4827-9555-e155c4afd20a%40 > googlegroups.com > >>>> <https://groups.google.com/d/msgid/django-users/e00f8c04- > 8c97-4827-9555-e155c4afd20a%40googlegroups.com?utm_medium= > email&utm_source=footer> > >>>> . > >>>> > >>>> For more options, visit https://groups.google.com/d/optout. > >>>> > >>> > >>> -- > >>> 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/ms > >>> gid/django-users/CAOs3Lp5V2Le%3DJWbSSp_%2B%2BsXK4KaN_3rB7-BV > >>> Hk6OSE8SgKoYFw%40mail.gmail.com > >>> <https://groups.google.com/d/msgid/django-users/ > CAOs3Lp5V2Le%3DJWbSSp_%2B%2BsXK4KaN_3rB7-BVHk6OSE8SgKoYFw%40mail.gmail. > com?utm_medium=email&utm_source=footer> > >>> . > >>> > >>> For more options, visit https://groups.google.com/d/optout. > >>> > >> > >> -- > >> 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/CAFWa6tKZcZLQ1BL7YhEqJpmmkv- > >> KLoxcRiMyMaTHsu7s3%2BA5%3DA%40mail.gmail.com > >> <https://groups.google.com/d/msgid/django-users/ > CAFWa6tKZcZLQ1BL7YhEqJpmmkv-KLoxcRiMyMaTHsu7s3%2BA5%3DA% > 40mail.gmail.com?utm_medium=email&utm_source=footer> > >> . > >> > >> For more options, visit https://groups.google.com/d/optout. > >> > > > > -- > > 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/ > CAOs3Lp6CPMUMAJfeRQFw0ihV7Ve3ggTWW0rL%3D4Q_V50bf4QEOA%40mail.gmail.com. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > 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/CALn3ei3VYWEjK02v9yd13NPk_cFn7x1RAHhT3yyiq_J4azX-jg% > 40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. > -- 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/CAOs3Lp7pFnuzpVWyHvKsK4JBUkWBbFUK3CCA6VwovczuCnaMgQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

