1👍
✅
If you want to improve speed (because 100 entries for each product, it’s really huge and it would be slow if you have to fetch 100 products and theirs points), I would use the pickle module and store your list of tuples in a TextField (or maybe CharField if the length of the string doesn’t change).
>>> a = [(1,2),(3,4),(5,6),(7,8)]
>>> pickle.dumps(a)
'(lp0\n(I1\nI2\ntp1\na(I3\nI4\ntp2\na(I5\nI6\ntp3\na(I7\nI8\ntp4\na.'
>>> b = pickle.dumps(a)
>>> pickle.loads(b)
[(1, 2), (3, 4), (5, 6), (7, 8)]
Just store b in your TextField and you can get back your list really easily.
And even better, as Robert Smith says, use http://pypi.python.org/pypi/django-picklefield
0👍
I like your second approach but just a minor suggestion.
class Plot(models.Model):
x_axis = models.PositiveIntegerField( ...)
y_axis = models.DecimalField( ...)
class Curve(models.Model)
plots = models.ManyToManyField(Plot)
class Diode(models.Model)
name = blah, blah
intensity = model.DecimalField(_('Diode Intensity'), blah, blah)
curve = models.ForeignKey(Curve)
Just a minor suggestion for flexibility
- [Answer]-How getting ManyToManyField("self") in the template?
- [Answer]-Name of view inside decorator_from_middleware class
Source:stackexchange.com