I have such a model in Django
:
class Event(models.Model):
EVENT_TYPE_CHOICES = [(e, e.value) for e in EVENT_TYPE]
event_type = models.TextField(choices=EVENT_TYPE_CHOICES)
date_of_event = models.DateTimeField(default=timezone.now, db_index=True)
event_data = JSONField()
And there is the event_data
JSONField
there which has the following structure:
'project_id': project_id,
'family_id': family_id,
'variant_data': variant_data_list,
'username': user.username,
'email': user.email,
Where variant_data_list
is a list of such dict
objects with 3
str
values:
{'xpos': xpos, 'ref': ref, 'alt': alt}
Now, I need a way to find unique Event
model object based on the supplied variant_data_list
(each object inside of it should be found within a single Event
s' variant_data_list
, is it possible to achieve somehow? The number of items in variant_data_list
is from 1
to 3
.
Otherwise I am thinking of generating unique ids based on the variant_data_list
each time it is written to postgres
(but not sure how to make it either). Any suggestions would be greatly appreciated.