0

I'm working on a project using django connecting to a MongoDB database using djongo. I have a few models and a few abstract models that I embed as ArrayModelFields. However when I try to use an ArrayModelField inside a model that is in-turn referenced as an ArrayModelField I get a 'nonetype' object is not iterable (not sure why).

I've gotten the system to work by combining the two models (Grade & Detail) into one in this case (after realizing the Grade model didn't need to exist) but is it possible at all to do what I wanted to do initially?

Before I've tried various embedding options for lists and arrays as listed in the djongo documentation but nothing else works.

class Grade(models.Model):
    kihon_Grade = models.CharField(max_length = 2, null = True)
    kata_Grade = models.CharField(max_length = 2, null = True)
    kumite_Grade = models.CharField(max_length = 2, null = True)
    class Meta:
        abstract = True

class Detail(models.Model):
    member = models.ForeignKey(to = Member, on_delete = None)
    rank = models.CharField(max_length = 10, null = True)
    grade = models.ArrayModelField(model_container = Grade, null = True)
    result = models.CharField(max_length = 10, null = True)
    class Meta:
        abstract = True

class Grading(models.Model):
    _id = models.ObjectIdField()
    examiner = models.CharField(max_length = 25, null = True)
    date = models.DateField(null = True, blank = True)
    detail = models.ArrayModelField(model_container=Detail, null=True, blank=True)
    def __str__(self):
        return self.date

I get the following exception thrown.

Django Version: 2.0

Exception Type: TypeError

Exception Value: 'NoneType' object is not iterable

Exception Location: D:\COMP405\COMP405\env\lib\site-packages\djongo\models\fields.py in has_changed, line 329

Python Executable: D:\COMP405\COMP405\env\Scripts\python.exe

Python Version: 3.7.2

Tisagh
  • 11
  • 3

0 Answers0