In the actual case I have more fields in the Record model, and repeating those fields in the Review model is not DRY.
If I create a model with "new" and "comment" and relate it to the Review, what would be the type of the field of the "new"? I want them to be, say, DateField for date fields, and an Integer field for integer fields, depending on the field type in the Record model. Thanks... On 3 Aralık, 18:05, "Marty Alchin" <[EMAIL PROTECTED]> wrote: > I'm a bit confused as to what you're actually trying to accomplish > here. Will there always only be three fields (a, b and c), or will > they actually be dynamic (and you could have many of them). If three > is just an arbitrary number, I think you're looking at creating a new > Model, containing "new" and "comment" and a ForeignKey back to Review. > But I'm not sure exactly what problem you're trying to solve yet, so I > can't say for sure if that'll help you. > > -Gul > > On Dec 3, 2007 10:16 AM, omat <[EMAIL PROTECTED]> wrote: > > > > > Hi all, > > > I have two models, such that, one holds a record, and the other holds > > reviews on that record, if any. > > > The (simplified) models look like this: > > > class Record(models.Model): > > a = models.CharField(max_length=10) > > b = models.DateField() > > c = models.IntegerField() > > > class Review(models.Model): > > a_new = models.CharField(max_length=10) > > a_comment = models.TextField() > > b_new = models.DateField() > > b_comment = models.TextField() > > c_new = models.IntegerField() > > c_comment = models.TextField() > > record = models.ForeignKey(Record) > > reviewer = modelsForeignKey(User) > > > As can be seen, for the fields in the Record model, I would like to > > have one field to store a new value, and one field to hold the > > comments on the new value. Fields that hold the new values will have > > the original type of their counterparts in the Record model while > > comments fields will be TextField for each original field. > > > And, for obvious reasons, I wish to create the part in the Review > > model that depends on the Record model dynamically. > > > I went through thehttp://code.djangoproject.com/wiki/DynamicModels > > andhttp://code.djangoproject.com/wiki/AuditTrail > > > Although what I wish for is much simpler than what those examples > > cover, I had no luck managing this. > > > I tried looping through the _meta.fields of the Record model but I > > couldn't manage to add them to the "base_fields" of the Review > > class. > > > Thanks for any help, > > oMat --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---