I'm building a Django project that has to do with generating math/science problems for teachers and students. The project works fine for some time but when I run it on the browser (with the views all set up) it sometimes get errors that I cant explain how they happen:
Example:
class Mymodel(models.Model):
attribute = JSONField() #it is a list of strings ['a', 'b', 'c']
def myfunc(self):
do something with (self.attribute)
The problem is that every now and then, the program runs into an error mainly because when myfunc calls self.attribute
it returns the list with items missing! Like, in this case, it may return ['a', 'b']
.
I've never seen any error like this, so I don't know what to do. I obviously double checked if the attribute is really with all the variables I expeceted it to be, that's not the problem. Has anyone seen anything like this that could help?
I strongly believe that it has something to do with how Django gets the data in the JSONField and parses it to a list or dict to work with that, but again I don't know what to do about it.