0
votes

In my Django project I am having RUntimeError when I'm supposed to get a 404. The description says:

Exception Value: maximum recursion depth exceeded

The error only occurs when I try to access a non-existent page (the correct result would be a 404 page isn't it?). Is this a Django bug or is it my fault? I will provide more information if needed.

EDIT: I have tried syncing the database (actually drop the database and sync it from scratch), restarting the server and even commenting out all the urlpatterns in all urls.py files.

EDIT: This is what the traceback looks like:

File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response
  83.                     request.path_info)
File "/usr/lib/pymodules/python2.6/django/core/urlresolvers.py" in resolve
  218.                     sub_match = pattern.resolve(new_path)
File "/usr/lib/pymodules/python2.6/django/core/urlresolvers.py" in resolve
  218.                     sub_match = pattern.resolve(new_path)
File "/usr/lib/pymodules/python2.6/django/core/urlresolvers.py" in resolve
  218.                     sub_match = pattern.resolve(new_path)

And the last few lines are:

File "/usr/lib/pymodules/python2.6/django/core/urlresolvers.py" in resolve
  218.                     sub_match = pattern.resolve(new_path)
File "/usr/lib/pymodules/python2.6/django/core/urlresolvers.py" in resolve
  216.             for pattern in self.url_patterns:
File "/usr/lib/pymodules/python2.6/django/core/urlresolvers.py" in _get_url_patterns
  245.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
2
Need more information. Sounds like your code ran into a loop and is repeating itself somewhere over and over. - Louis
does any function get called if I don't have anything in urls.py? - phunehehe
If you don't have any urls in urlpatterns, it should say "It Works" aka the django default. There could be a problem in your settings, check ROOT_URLCONF in settings.py - Louis
Thanks Louis the problem was really in settings.py, I tried building one from scratch and it works. If you make an answer I will accept it :) - phunehehe

2 Answers

0
votes

I guess this is your fault :). I also had a RuntimeError yesteday. It was caused by giving the wrong class as argument of the super method when inheriting a ModelAdmin class.

class MyAdmin(admin.ModelAdmin):
    def queryset(self, request):
        qs = super(AnotherAdmin, self).queryset(request)
        ...

I've fixed by:

class MyAdmin(admin.ModelAdmin):
    def queryset(self, request):
        qs = super(MyAdmin, self).queryset(request)
        ...

I don't know if you have the same problem but it is something to check.

I hope it helps

0
votes

try not loading all middleware modules, just comment them all in the settings and see if the problem is somewhere there.