GitHub user dosubot[bot] added a comment to the discussion: Is there an inbuilt
class in Superset called SuperstDashboardIndexView
<!-- Answer -->
Yes, your redirect logic will work as intended in Superset 5, but you need to
combine it with your existing FLASK_APP_MUTATOR (view1) function. Only one
FLASK_APP_MUTATOR is supported, so all customizations—setting a custom
IndexView, adding views/links, and registering before_request hooks—must be
done inside that single function.
Here's how you can do it:
1. Define your custom IndexView class (with your redirect logic) outside the
view1 function.
2. Inside view1, after importing appbuilder, set appbuilder.indexview =
SupersetDashboardIndexView.
3. Keep your existing logic (adding views, links, before_request) as is.
Example:
```python
from flask_appbuilder import expose, IndexView
from superset.typing import FlaskResponse
from flask import g, redirect
class SupersetDashboardIndexView(IndexView):
@expose("/")
def index(self) -> FlaskResponse:
if not g.user or not get_user_id():
return redirect("/login")
return redirect(WELCOME_PAGE_REDIRECT_DEFAULT)
def view1(SupersetsetApp):
from superset.extensions import appbuilder
from superset.views.user_D.views import DashboardModelView1
import time
# Your existing logic...
user_info_cache = {}
CACHE_TTL = 10
appbuilder.add_view_no_menu(DashboardModelView1)
appbuilder.add_link(
"User Details",
label="User Details",
href="/userdetails/form",
icon="fa-dashboard",
category="",
category_icon="",
)
@SupersetsetApp.before_request
def track_user_visit():
# ... your tracking logic ...
# Set your custom IndexView here
appbuilder.indexview = SupersetDashboardIndexView
return SupersetsetApp
FLASK_APP_MUTATOR = view1
```
This approach is supported and recommended for Superset 5—just make sure all
your app customizations are inside the single FLASK_APP_MUTATOR function, and
set appbuilder.indexview to your custom class before returning the app. If you
run into issues, double-check your config file placement and syntax, and
restart your Superset instance for changes to take effect. See more details in
the [official discussion](https://github.com/apache/superset/discussions/34530)
and [migration issue](https://github.com/apache/superset/issues/34441).
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
---
<sup>How did I do?
[Good](https://app.dosu.dev/response-feedback/24d83e80-6119-4ab0-b0bd-5bc9f8d7dc15?feedback_type=great_response)
|
[Irrelevant](https://app.dosu.dev/response-feedback/24d83e80-6119-4ab0-b0bd-5bc9f8d7dc15?feedback_type=irrelevant_answer)
|
[Incorrect](https://app.dosu.dev/response-feedback/24d83e80-6119-4ab0-b0bd-5bc9f8d7dc15?feedback_type=incorrect_sources)
|
[Verbose](https://app.dosu.dev/response-feedback/24d83e80-6119-4ab0-b0bd-5bc9f8d7dc15?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/24d83e80-6119-4ab0-b0bd-5bc9f8d7dc15?feedback_type=hallucination)
| [Report
🐛](https://app.dosu.dev/response-feedback/24d83e80-6119-4ab0-b0bd-5bc9f8d7dc15?feedback_type=bug_report)
|
[Other](https://app.dosu.dev/response-feedback/24d83e80-6119-4ab0-b0bd-5bc9f8d7dc15?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
nbsp;[](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/34594)
GitHub link:
https://github.com/apache/superset/discussions/34594#discussioncomment-14033750
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]