python - Django: correct way to specify model (list of tuples) -


i'm not happy current model , wanted ask if there better/preferred way achieve same result.

what want?

  • an object contains number of lists. each list contains tuples, first entry being date object, second 1 either float or integer.
  • if delete a, b should deleted. if delete b want have empty list.

how tried accomplish it:

class timevalueintsequence(models.model):     pass  class timevaluefloatsequence(models.model):     pass  class timevalueint(models.model):     time = models.datefield()     value = models.integerfield()     sequence = models.foreignkey(timevalueintsequence, models.cascade, blank=false, null=false)  class timevaluefloat(models.model):     time = models.datefield()     value = models.floatfield()     sequence = models.foreignkey(timevaluefloatsequence, models.cascade, blank=false, null=false)  class a(models.model):     field1 = models.onetoonefield(timevalueintsequence, models.set_null, blank=true, null=true, related_name='field1')     field2 = models.onetoonefield(timevalueintsequence, models.set_null, blank=true, null=true, related_name='field2')     field3 = models.onetoonefield(timevaluefloatsequence, models.set_null, blank=true, null=true, related_name='field3') 

what wrong?

  • approach seems inefficient.
  • if delete object of type sequences not deleted.

do have feedback? thank you!

i couldn't find better solution ended using json. if have same problem make sure use djangojsonencoder deal date-time objects.

remark: nice if django abstract , enable story arbitrary datatypes long serializable. if know how, let me know.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -