Skip to content

Crashing with self foreign key, maximum recursion depth exceeded. #5

@luismmontielg

Description

@luismmontielg

Hello, Im getting this error:

My class has a foreign key to self.

class Category(models.Model):
name = models.CharField(("name"), unique=True, max_length=100)
slug = models.SlugField(
("slug"))
parent = models.ForeignKey('self', blank=True, null=True, related_name='child')

At some point, it goes into this:

File "…/django-cachebot/cachebot/queryset.py", line 138, in _get_join_paths
for model_class, join_accessor_path in self._get_join_paths(join_tuple[0], join_tuple[2]):

File "…/django-cachebot/cachebot/queryset.py", line 138, in _get_join_paths
for model_class, join_accessor_path in self._get_join_paths(join_tuple[0], join_tuple[2]):

..... again
..... again ....

Then finally:

File ".../django-cachebot/cachebot/queryset.py", line 130, in _get_join_paths
model_class, m2m = self.queryset._get_model_class_from_table(table_alias)

File "....django-cachebot/cachebot/queryset.py", line 184, in _get_model_class_from_table
model_class = [m for m in get_models() if connection.introspection.table_name_converter(m._meta.db_table) in map(connection.introspection.table_name_converter,[table])][0]

RuntimeError: maximum recursion depth exceeded

Any ideas?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions