[Fixed]-Django/Python Runtime Error: Maximum recursion depth exceeded

46👍

You seem to be including blogapp.urls inside itself. Doesn’t sound like a good idea.

4👍

The problem is that django logout method is in your view logout method. So it calls itself and never ends.

So you may rename your view logout method as ‘signout’ or something like that.

Other way is import django logout with other name like below and called it in your logout method:
from django.contrib.auth import logout as core_logout

👤Dat TT

1👍

I got the similar error:

RecursionError: maximum recursion depth exceeded in comparison

When creating and saving Person object in save() overridden in Person class as shown below:

from django.db import models

class Person(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)

    # ...
    
    def save(self, *args, **kwargs): # Here
        person = Person(first_name='Soi', last_name='Tato')
        person.save()

So, it seems like person.save() calls save() in Person class again and again, then finally caused the error.

-2👍

I would assume you’re trying to create member object properties

''represents a class instance of a blog entry'''
    title = models.CharField(max_length=100)
    created = models.DateTimeField()
    body = models.TextField()

which should ideally go into the constructor method under

 def __init__(self):
''represents a class instance of a blog entry'''
    title = models.CharField(max_length=100)
    created = models.DateTimeField()
    body = models.TextField()

Leave a comment