Re: Dynamic Models

2017-01-10 Thread Guilherme Leal
Well, some more context then: I've worked at a company that have exactly the same logic writen in perl and using an ORM built inside the company. The ideia was to build a plataform to interact with the DB, and with this interaction, extend the information about the table been created/modified or t

Re: Dynamic Models

2017-01-10 Thread Jani Tiainen
Problem, as you see is that Django is build for static models. So if you have a dynamic model, how would you construct (efficient) queries in your other views unless you know the structure of the data? Well you kind of can't since there is no structure. Also, what purpose would such a models s

Re: Dynamic Models

2017-01-10 Thread Guilherme Leal
@Jani Tiainen I really like Django ORM, and will make everything possible to keep it. I think that losing the ORM will make things harder in the big picture because it would make the logic built by the developers a lot more error prone and not "database agnostic" (at least as far as thedatabases ba

Re: Dynamic Models

2017-01-09 Thread Jani Tiainen
Hi, You're probably after EAV pattern (or anti-pattern depending who you ask). Implementing that in Django is relatively trivial, though with any kind of dynamics you'll going to loose most of the ORM goodies. This kind of leads to question that is Django ORM really needed for you at all? Ho

Re: Dynamic Models

2017-01-06 Thread Guilherme Leal
@Michal Petrucha That was one of the insights that I've been wanted. One way or another I will try, but will keep in mind these points. Thank you! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving

RE: Dynamic Models

2017-01-05 Thread Matthew Pava
ango-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Vijay Khemlani Sent: Thursday, January 5, 2017 4:00 PM To: django-users@googlegroups.com Subject: Re: Dynamic Models "That was exacly the points i'm willing to avoid. Had any problems with the metaclass approach? W

Re: Dynamic Models

2017-01-05 Thread Vijay Khemlani
"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?" We had to represent multiple product categories, each with their own structure and particular fields. In the end we had around 700 virtual models, which

Re: Dynamic Models

2017-01-05 Thread Michal Petrucha
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

RE: Dynamic Models

2017-01-05 Thread Matthew Pava
@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Guilherme Leal Sent: Thursday, January 5, 2017 1:06 PM To: django-users@googlegroups.com Subject: Re: Dynamic Models @Matthew Pava >Going down that route, we would basically be developing an IDE for Django >models Well, th

Re: Dynamic Models

2017-01-05 Thread Guilherme Leal
@ > 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 >

RE: Dynamic Models

2017-01-05 Thread Matthew Pava
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

Re: Dynamic Models

2017-01-05 Thread Guilherme Leal
@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 : > Would it work if the interface provide a download for a bunch of > models.py file ? > > 2017-01-05 19:12 GMT+01:00

Re: Dynamic Models

2017-01-05 Thread Guilherme Leal
@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 : > I had to implement dynamic models

Re: Dynamic Models

2017-01-05 Thread ludovic coues
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 : > 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

Re: Dynamic Models

2017-01-05 Thread Vijay Khemlani
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

Re: Dynamic Models

2017-01-05 Thread Guilherme Leal
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

Re: Dynamic Models

2017-01-05 Thread Avraham Serour
you should read about metaclasses, basically it enables you to build class definitions in runtime. http://stackoverflow.com/questions/13/what-is-a-metaclass-in-python On Thu, Jan 5, 2017 at 6:02 PM, Guilherme Leal wrote: > The "migrations on the fly" thing dont get to be a problem (since I

Re: Dynamic Models

2017-01-05 Thread Guilherme Leal
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 p

Re: Dynamic Models

2017-01-05 Thread Beautifulloop
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, Guilh

Re: Dynamic Models

2017-01-05 Thread Guilherme Leal
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 : > I guess you could play with metaclass

Re: Dynamic Models

2017-01-05 Thread Avraham Serour
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 wrote: > Is there a

Re: Dynamic Models for CSV Importing

2013-04-15 Thread Max Demars
Hello André, I wonder if you successfuly found a way to achieve what you were talking in this post. Actually, I am looking for something similar. Instead of uploading .csv my app would allow users to upload shapefile. I am reading about dynamic models but the doc is scarce. If you can share a b

Re: Dynamic Models for CSV Importing

2011-06-20 Thread Andre Terra
Thanks for the quick reply, Shawn! The reason I wanted to use Django was so that I could leverage the ORM to allow users to do arbitrary SQL filtering/grouping before the data gets saved onto the production DB. Assuming a 1.5 million lines CSV file (which is probably the smallest file users would

Re: Dynamic Models for CSV Importing

2011-06-20 Thread Shawn Milochik
I don't see where Django comes in -- at least not for the core of the app. Python certainly, with the xlwt and xlrd modules being incredibly helpful. Secondly, I'd use MongoDB (via pymongo) to store the temporary data, because I wouldn't bet a nickel that you'll get data in a consistent forma

Re: Dynamic models keyError

2008-07-04 Thread Malcolm Tredinnick
On Fri, 2008-07-04 at 09:28 -0700, mwebs wrote: > Hello, > > I am trying to generate models at runtime. For this purpose I am using > the method create_model() provided at > http://code.djangoproject.com/wiki/DynamicModels > > create_model(name, fields, module='app.models' ) > > When I am doin

Re: Dynamic Models

2008-01-11 Thread Marty Alchin
On Jan 11, 2008 10:39 AM, WoonZai <[EMAIL PROTECTED]> wrote: > >>> model = create_model('Empty') > Traceback (most recent call last): > File "", line 1, in > File "/Users/../models.py", line 36, in create_model > return type(UserForm, (models.Model,), attrs) > File "/.../site-packages/d