Good day. Please help with the following question.
It is necessary to describe the tree model in Django. The database used is Oracle.
I describe it this way:
class TelDivisions(models.Model): parent = models.ForeignKey('self') name = models.CharField(max_length=50, blank=True) class Meta: db_table = u'tel_divisions' but in this way parent refers to itself. How to make it refer to the id column of this table?
I thought it might turn out like this:
class TelDivisions(models.Model): parent = models.ForeignKey(TelDivisions, db_column='id', blank=True) name = models.CharField(max_length=50, blank=True) class Meta: db_table = u'tel_divisions' but the python manage.py validate command revealed:
parent = models.ForeignKey(TelDivisions, db_column='id', blank=True) NameError: name 'TelDivisions' is not defined What, in fact, is logical. How to be?
Thank.