Dynamic Fields and Saving data per user
I am trying to make an app where each user will have like a mailing
list for which they should be-able to create custom fields for any
data they may want to hold and be able to save multiple rows of that
data.
I was thinking to use a model to hold the fields definitions and a key
value system to hold the data, something like this:
class Maillist(models.Model):
user = models.ForeignKey(User)
....
class Subscriber(models.Model):
email = models.EmailField()
list = models.ForeignKey(List)
class ListField(models.Model):
list = models.ForeignKey(Maillist)
field_type = models.IntegerField(choices=FIELD_TYPE_CHOICES)
label = models.CharField(_('Label'), max_length=100)
class SubscriberData(models.Model):
subscriber= models.ForeignKey(Subscriber, db_index=True)
key = models.ForeignKey(ListField, db_index=True)
value = models.CharField(max_length=240, db_index=True)
Would this even work properly? Is there some better way to do it, what
about dynamically creating a model and its fields for each MailList?
--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home