Django specific fields for end users, how?

Possible duplicate:
Dynamic Django models

Good morning, guys! The scenario is as follows. For some models on Django, I would like to allow the end user to define his own fields. It would be great if I could save all the awesome Django features like ORM, so I can still make calls like field__gte to search by model, there is still a field check according to the type of field, etc. I thought of two ways to accomplish this, and I'm more than open to new suggestions. Any feedback would be VERY appreciated.
  • 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, . !

+5
2

NoSQL, MongoDB, , ( , ).

:

:

EDIT:

, NoSQL, , . CouchDB, , .

+1

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)

+1

All Articles