0

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.

Brian Destura
  • 11,487
  • 3
  • 18
  • 34
  • 1
    We can't possibly help without seeing the code... – John Gordon Jul 26 '21 at 00:04
  • There's no between code in the problem I'm relating. The problem is plainly this: the variable is a list with some items. When I call a function that uses that list, it sometimes brings a list with an item missing. The rest of the code doesn't have to do with this, but it depends on it. – Franklin Santos Jul 26 '21 at 03:56
  • Then the only answer we can give is "you have wrong code somewhere". – John Gordon Jul 26 '21 at 04:29

0 Answers0