Hi all. I have a number of models, each of which is based on an abstract
class that includes a Timestamp field. The model definitions look like
this:
class Md_model(models.Model):
Timestamp =
models.DateTimeField(auto_now_add=True,unique=True,db_index=True)
def __unicode__(self):
return self.Timestamp.strftime('%Y %m %d %H:%M')
def as_dict(self):
return(model_to_dict(self))
class Meta:
abstract = True
class md_10_1(Md_model):
name='md_10_1'
dataSource = 'http://192.168.0.10/auto/001'
n1 = models.DecimalField(max_digits=10,decimal_places=3)
n2 = models.DecimalField(max_digits=10,decimal_places=3)
n3 = models.DecimalField(max_digits=10,decimal_places=3)
class md_10_2(Md_model):
name='md_10_2'
dataSource = 'http://192.168.0.10/auto/002'
n4 = models.DecimalField(max_digits=10,decimal_places=3)
n5 = models.DecimalField(max_digits=10,decimal_places=3)
What I want to do is join them all (actually some programatically defined
subset of them) into a single query set or some other data structure that I
can pass into the template. This set would have only one Timestamp field,
and all of the other fields from all of the other models that are to be
joined. She thre result would have Timestamp, n1, n2, n3, n4, n5 in the
example above,
Using a foreign key does't make sense to me since I can't predict that any
particular model will be in every query.
I think that what I need to do is iterate in parallel over three or more
iterables and merge them, but I don't know how.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/jdJnB7mUODMJ.
To post to this group, send email to [email protected].
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.