Possible duplicate:Dynamic Django models
The first approach is the Entity-Attribute-Value attribute ( http://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model ), in which django already has an application for, See http : //code.google.com/p/django-custom-field/ I think it will be OK, but I lose the ability to do "mymodel.objects.filter (custom_field_x = something)". Maybe there is a way to return ORM, any ideas? But I have heard so many bad stories about this method that I am a little afraid to use it.
The second approach is to have a database table for each of the users (possibly no more than 1000). I read that django has something in inspectdb lines that actually checks which fields are there and produces a model for you. It may be useful, but I think maybe I should save the fields created by this particular user, and somehow dynamically tell django, hey, we also have these fields in this model. Is it possible? I know that in general it’s bad to have different tables for each user, but given this scenario, how would you guys rate this method, would it be nice to have one table for each user?
A model that requires custom fields is, for example, Person. They may need a custom field to store an address, such as blood or any other thing.
Many thanks in advance! Have a nice sunday!
: Django, EAV, . !
NoSQL, MongoDB, , ( , ).
:
EDIT:
, NoSQL, , . CouchDB, , .
user_defined_fields?
class UserDefinedField(models.Model): #.................. user = models.ForeignKey(User) field_name = models.CharField(max_length=50) field_value = models.TextField()
UserDefinedField.objects.filter(field_name=some_name,field_value=somevalue)