views:

79

answers:

1

Hello!

I am having a rather weird problem in a sense that I can't understand what it might be. My site uses django-registration and all works fine, but if I restart django dev. server in the middle of the session (i.e. been logged in) I immediately get error:

Caught an exception while rendering: Reverse for 'django.contrib.auth.decorators._CheckLogin object at 0x235aa50' with arguments '()' and keyword arguments '{}' not found.

Once again: all works fine if I don't restart dev. server. This error happens if and only if I restart djange dev. server been logged into my site.

+4  A: 

The URL reverse functionality in Django is unfortunately very brittle. It works by importing all the views, and seeing which ones match. If, for some reason, it can't import a view - any view attached to a URLconf - then the entire reverse match fails.

So, sometimes there are some dependencies in your views which mean that they can't be imported straight after you have restarted the server. This causes all URL reverse matches to fail, even those that have nothing to do with the view with the problem. But if you refresh the page, you often find that the error goes away.

The error is likely not in django-registration at all, but somewhere very obscure in one of your own views. I would try commenting out all the other urls, then re-enable them one by one - restarting the dev server each time - to see when the error appears.

Daniel Roseman