Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to add standalone view #1

Closed
ommyan opened this issue Jul 23, 2018 · 4 comments
Closed

how to add standalone view #1

ommyan opened this issue Jul 23, 2018 · 4 comments

Comments

@ommyan
Copy link

ommyan commented Jul 23, 2018

dear Jonalxh,

i tried to develop app from your boilerplate, this is a great boilerplate. i have a problem , how to add a standalone view, i followed this documentation :

`from flask_admin import BaseView, expose

class AnalyticsView(BaseView):
    @expose('/')
    def index(self):
        return self.render('analytics_index.html')

admin.add_view(AnalyticsView(name='Analytics', endpoint='analytics'))`

and in analytics_index.html i write code below

`{% extends 'admin/master.html' %}
{% block body %}
  <p>Here I'm going to display some data.</p>
{% endblock %}`

i sad, i get error :
Exception: Attempted to instantiate admin view AnalyticsView without default view

may i know, step by step how to add a standalone view

thank you verrymuch

@jonalxh
Copy link
Owner

jonalxh commented Jul 23, 2018

Hi friend.

In theory your process is well done.

In addition of your code I've added {{ super() }} after body block instance, i.e in your analytics_index.html:

{% extends 'admin/master.html' %}
{% block body %}
{{ super() }}
    <p>Here I'm going to display some data.</p>
{% endblock body %}

It should work.

I've updated the repository adding a custom view item in the left menu, which redirects to a custom html view without DB model dependence, please pull the project and try to test it.

Let me know if it works for you.

@ommyan
Copy link
Author

ommyan commented Jul 24, 2018

dear Jonalxh,

thank for quick response, this work like charm,...

salut

@jonalxh
Copy link
Owner

jonalxh commented Jul 24, 2018

I'm glad to know that it works correctly.

I procceed to close the issue.

@jonalxh jonalxh closed this as completed Jul 24, 2018
@ommyan
Copy link
Author

ommyan commented Jul 24, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants