Reputation: 1401
This is my application structure:
/blog
/blog
/app.py
models.py
views.py
/admin
__init__py
views.py
...
I want to use flask-admin extension in a different package.
in /admin/__init__.py
I imported the app and flask-admin extension:
from flask.ext.admin import Admin
from app import app
then I initiate the admin app like that:
admin = Admin(app)
However, I get 404 error. Why? Should I use blueprint or what?
Upvotes: 0
Views: 354
Reputation: 4306
I assume you're trying to hit the default /admin
routes within your Flask app for Flask admin?
My guess right now is that none of your code does import admin
anywhere, which is probably good since admin's __init__.py
will try to re-import your app.py all over again (from the from app import app
reference) and you'll end up in a circular dependency.
What I'd do is alter app.py to contain the admin = Admin(app)
and from flask.ext.admin import Admin
code, and also do a from admin import views
and empty out the admin/__init__.py
file completely.
Upvotes: 2