[Answered ]-How to fix ViewDoesNotExist at /admin/

2👍

This is usually an indication that the view in question does not exist or is not accessible by the admin panel. Are you sure you imported it, or included it as necessary?

0👍

It looks to me like you’ve created an error that relates to your question view, and that’s what’s breaking the admin (Could not import restaurants.views.question). It’s not actually an error with admin, or a new bug in the body of the restaurants.views module.

My guess is that you’ve created a circular import – Look at the imports at the top of your restaurants.views module. Now check each module that you’re importing from and look see if that module imports from restaurants.views.

If that doesn’t show anything check all the imports in all the models that are imported into your restaurants.views module and look for something there.

I’ve seen this a few times since using class based views. Obviously the whole point of class based views is that they can be extended. This can lead to circular dependencies. Unless I’ve only got a couple of views in my app, I tend to split everything out of a single file and create a views directory –

my_app
    views
        __init__.py
        view1.py
        view2.py
        view3.py

Then add the following import statements to your __init__.py so everything works as before –

from view1 import View1
from view2 import View2
from view3 import View3

This allows you to have much fewer import statements at the top of each view module reducing the risk of a circular dependency.

Leave a comment