Re: Dynamic class definitions
On Dec 5, 2007 12:25 PM, DeliciousPy <[EMAIL PROTECTED]> wrote: > As for Marty's response... > >However, I haven't looked at what it > > would take to actually commit changes to the already-synced tables. I > > have a feeling Django Evolution[2] will help with this, but I haven't > > done any testing with it yet. > > Yeah, I've seen the DynamicModels writeup, but there is that issue of > syncing modifications to models. Evolution might help, but as far as I > can tell that will look at the models.py file, not database entries, > so that brings me back to my original question of whether I should > build some kind of script/app to edit models.py files. A cursory look at the django-evolution source reveals what I expected: it looks at the in-memory model class. Ordinarily, this will be created by writing a model in models.py directly, but it's quite possible to use database-backed model definitions and have them show up in an app's 'models' module. Django evolution would then have no way of knowing whether the model was written out by hand, or generated dynamically. I admit, I haven't done a thorough test of storing model definitions in a database, but it really should work, and without having to automatically build/edit your models.py file. Now that Django Evolution is gaining traction, I may set up a separate Google Code project just to create an app for managing dynamic models. I don't know yet though, and I certainly wouldn't have it done in the next few days or anything, so if you have more urgent need, feel free to continue with it on your own. I'd be happy to answer any questions you have about the process, to the best of my ability. -Gul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Dynamic class definitions
> From your description, I don't understand why your models need to be > dynamic. If each Item is defined in terms of it's Type and Fields, > then can you not change the definition on an Item by simply adding new > ItemTypes and ItemFields? If you're talking about using ItemField Classes, I could, but then there would no real instances of items other than as a collection of foreign keys, and instead my items are stored in instances of different item field classes. and I get tables that consist of instances of the various types of fields available (i.e. a table full of charfields, which is holding all the data for all the charfields of my items). As for them needing to be dynamic, it's that I want end-users (who wouldn't have access to models,py and the know-how to change it) to be able to add fields to items, like "model" or "manufacturer", etc. to fit their needs. At my current job I use a CRM system that has all these unnecessary fields for all kinds of records. It would be wonderful if the end- users (say, accounting, or warehouse manager, or whatever) could put in the fields as required (which we can do, but we can't get rid of the default ones), so that anyone entering in a new instance of an item could later fill out the fields. As for Marty's response... >However, I haven't looked at what it > would take to actually commit changes to the already-synced tables. I > have a feeling Django Evolution[2] will help with this, but I haven't > done any testing with it yet. Yeah, I've seen the DynamicModels writeup, but there is that issue of syncing modifications to models. Evolution might help, but as far as I can tell that will look at the models.py file, not database entries, so that brings me back to my original question of whether I should build some kind of script/app to edit models.py files. Matt, the custom_model_fields link will probably come in handy. Thanks! -D. Py --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Dynamic class definitions
> I want to be able to change the definition of an existing class (and > the associated parts of the DB) during runtime, from a web interface. > I'll describe the model I want to implement... > Say I have three classes: Item, Item Type, (and possibly) Item Field >From your description, I don't understand why your models need to be dynamic. If each Item is defined in terms of it's Type and Fields, then can you not change the definition on an Item by simply adding new ItemTypes and ItemFields? > Another requirement is the ability to have "complex fields" that is, > small collections of fields that go together, like a boolean field > (represented by a checkbox) used to specify if a partner charfield > should do one thing or another. If the complexity exists at the data level, you may find that Django's 'custom model fields' [1] will help you with that. Otherwise, if the complexity is just presentation/form-based, you can use custom form fields/widgets. See James Bennett's excellent writeup on newforms for more on that (and newforms in general) [2]. Matt. [1] http://www.djangoproject.com/documentation/custom_model_fields/ [2] http://www.b-list.org/weblog/2007/nov/23/newforms/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Dynamic class definitions
You might take a look at my writeup on dynamic models,[1] which specifically covers a way to specify Django models in a database, which can be changed at run-time. However, I haven't looked at what it would take to actually commit changes to the already-synced tables. I have a feeling Django Evolution[2] will help with this, but I haven't done any testing with it yet. -Gul [1] http://code.djangoproject.com/wiki/DynamicModels [2] http://code.google.com/p/django-evolution/ On 12/5/07, DeliciousPy <[EMAIL PROTECTED]> wrote: > > I'm thinking of trying to start making a CRM/ERP system, I had just > started working on an inventory app, when I ran into a problem. > > I want to be able to change the definition of an existing class (and > the associated parts of the DB) during runtime, from a web interface. > > > I'll describe the model I want to implement... > Say I have three classes: Item, Item Type, (and possibly) Item Field > > Items would consist of an item type, and item fields (separate from > the so-named classes) > > Item types would specify groups of item fields shown in item records > (instances of the item class), and would also specify how the fields > interacted with other parts of the database (ie accounting, sales, > etc) > > Item fields would consists of a field name, a field type and a > description of the field. This class might not be necessary, depending > on how this would be implemented. > > Another requirement is the ability to have "complex fields" that is, > small collections of fields that go together, like a boolean field > (represented by a checkbox) used to specify if a partner charfield > should do one thing or another. > > > One way I was thinking of doing this would involve a view that would > invoke a script that writes django code to do the dirty work of > inserting stuff into models.py files and updating the db > appropriately. I feel like there might be a better way, or perhaps > something that does this already... > > > So my questions are: > > Are there currently any existing methods of doing this kind of thing > with Django (or something built for this purpose), and if not, what > are your thoughts on how I should proceed? > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Dynamic class definitions
I'm thinking of trying to start making a CRM/ERP system, I had just started working on an inventory app, when I ran into a problem. I want to be able to change the definition of an existing class (and the associated parts of the DB) during runtime, from a web interface. I'll describe the model I want to implement... Say I have three classes: Item, Item Type, (and possibly) Item Field Items would consist of an item type, and item fields (separate from the so-named classes) Item types would specify groups of item fields shown in item records (instances of the item class), and would also specify how the fields interacted with other parts of the database (ie accounting, sales, etc) Item fields would consists of a field name, a field type and a description of the field. This class might not be necessary, depending on how this would be implemented. Another requirement is the ability to have "complex fields" that is, small collections of fields that go together, like a boolean field (represented by a checkbox) used to specify if a partner charfield should do one thing or another. One way I was thinking of doing this would involve a view that would invoke a script that writes django code to do the dirty work of inserting stuff into models.py files and updating the db appropriately. I feel like there might be a better way, or perhaps something that does this already... So my questions are: Are there currently any existing methods of doing this kind of thing with Django (or something built for this purpose), and if not, what are your thoughts on how I should proceed? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---