Consider adding an extra table, 'item_type_extra_properties' or
something like that, used to store all those types of properties which
are not yet known at design-time.

--Tim

-----Original Message-----
From: django-users@googlegroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Malcolm Tredinnick
Sent: maandag 13 maart 2006 12:27
To: django-users@googlegroups.com
Subject: Re: Adding new properties post sql build


On Mon, 2006-03-13 at 11:10 +0000, Panos Laganakos wrote:
> Hello,
> 
> I have an item_type table which allows the user to add new types of
> items himself. Problem is that except the basic properties that are
> included in the item table, he might need to define item specific ones
> (properties).
> 
> I discussed it a bit with a friend and talked about adding an extra
> field on the item_type table (varchar field) to define new properties
> in a dictionary form of key value pairs,
> 
> ie. "newprop1=value1;newprop2=value2".
> 
> I'm not sure if this is considered good practice when using the django
> framework, and in the end, will I be able to provide an admin
interface
> for this kind of field, specialized to that specific pattern?
> 
> Also any other suggestion for that kind of issue would be appreciated,

If I am undertsanding what you want correctly, you could make properties
a separate table and then set up a one-to-many relationship between the
item_type table and the properties table.

The properties table would basically contain two fields: 'property name'
and 'value' and you would put a ForeignKey field in the item_type table.

That is a fairly normal way of associating arbitrary extra data with a
particular object. Your idea of adding an extra field is really just
flattening the one-to-many relation into a single string. In essence,
you are doing some of the work that is normally done by the database
yourself.

Regards,
Malcolm





--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to