Going down that route, we would basically be developing an IDE for Django models. It would definitely be possible, but it would involve a lot of work. Maybe it could even be integrated into django-admin one day.
You may want to check out http://www.web2py.com/ which does its own web IDE for Python including its models, though it’s not Django. From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Guilherme Leal Sent: Thursday, January 5, 2017 12:28 PM To: django-users@googlegroups.com Subject: Re: Dynamic Models @ludovic coues Like what? let the interface generate the python models? I thought about that, but it doesnt seem viable. Have any ideias? 2017-01-05 16:26 GMT-02:00 ludovic coues <cou...@gmail.com<mailto:cou...@gmail.com>>: Would it work if the interface provide a download for a bunch of models.py file ? 2017-01-05 19:12 GMT+01:00 Vijay Khemlani <vkhem...@gmail.com<mailto:vkhem...@gmail.com>>: > 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 <lealhu...@gmail.com<mailto:lealhu...@gmail.com>> > 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 >> <tovm...@gmail.com<mailto:tovm...@gmail.com>>: >> >>> 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 >>> <lealhu...@gmail.com<mailto:lealhu...@gmail.com>> >>> 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 >>>> <darahs...@gmail.com<mailto:darahs...@gmail.com>>: >>>> >>>>> 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 >>>>>> <tov...@gmail.com<mailto:tov...@gmail.com>>: >>>>>> >>>>>>> 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 >>>>>>> <leal...@gmail.com<mailto:leal...@gmail.com>> >>>>>>> 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 >>>>>>>> django-users...@googlegroups.com<mailto:django-users...@googlegroups.com>. >>>>>>>> To post to this group, send email to >>>>>>>> django...@googlegroups.com<mailto:django...@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/CAOs3Lp7_R4RK >>>>>>>> %3DVconoQ1W6rzK8xYaiVJX-FHtyZ3Cxg4MmbOow%40mail.gmail.com<http://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 >>>>>>> django-users...@googlegroups.com<mailto:django-users...@googlegroups.com>. >>>>>>> To post to this group, send email to >>>>>>> django...@googlegroups.com<mailto:django...@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/CAFWa6t%2B5DO >>>>>>> 5u8p5fRrGAGkW1KYR2DZxc_wtkNQG7bX3u6v7JuA%40mail.gmail.com<http://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 >>>>> django-users+unsubscr...@googlegroups.com<mailto:django-users%2bunsubscr...@googlegroups.com>. >>>>> To post to this group, send email to >>>>> django-users@googlegroups.com<mailto: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/ms >>>>> gid/django-users/e00f8c04-8c97-4827-9555-e155c4afd20a%40googlegroups.com<http://40googlegroups.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 >>>> django-users+unsubscr...@googlegroups.com<mailto:django-users%2bunsubscr...@googlegroups.com>. >>>> To post to this group, send email to >>>> django-users@googlegroups.com<mailto: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/ms >>>> gid/django-users/CAOs3Lp5V2Le%3DJWbSSp_%2B%2BsXK4KaN_3rB7-BV >>>> Hk6OSE8SgKoYFw%40mail.gmail.com<http://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 >>> django-users+unsubscr...@googlegroups.com<mailto:django-users%2bunsubscr...@googlegroups.com>. >>> To post to this group, send email to >>> django-users@googlegroups.com<mailto: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/CAFWa6tKZcZLQ1BL7YhEqJpmmkv- >>> KLoxcRiMyMaTHsu7s3%2BA5%3DA%40mail.gmail.com<http://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 >> django-users+unsubscr...@googlegroups.com<mailto:django-users%2bunsubscr...@googlegroups.com>. >> To post to this group, send email to >> django-users@googlegroups.com<mailto: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/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 > django-users+unsubscr...@googlegroups.com<mailto:django-users%2bunsubscr...@googlegroups.com>. > To post to this group, send email to > django-users@googlegroups.com<mailto: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/CALn3ei3VYWEjK02v9yd13NPk_cFn7x1RAHhT3yyiq_J4azX-jg%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. -- Cordialement, Coues Ludovic +336 148 743 42<tel:%2B336%20148%20743%2042> -- 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<mailto:django-users%2bunsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com<mailto: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/CAEuG%2BTZhYhyNKtx%2BfEK1ovruSqXMuKuQk4pqcGt8kADYPF4xyw%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 django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com<mailto: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/CAOs3Lp5HO4O%2BdJ-v15Q4Y%2BDjbLB0%3DtgAx0NyFjjGbMzt9KoAWw%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAOs3Lp5HO4O%2BdJ-v15Q4Y%2BDjbLB0%3DtgAx0NyFjjGbMzt9KoAWw%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 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/52d1aa0e82e44579a728372a6618957c%40ISS1.ISS.LOCAL. For more options, visit https://groups.google.com/d/optout.