pallets-eco / flask-admin

Simple and extensible administrative interface framework for Flask
https://flask-admin.readthedocs.io
BSD 3-Clause "New" or "Revised" License
5.69k stars 1.56k forks source link

Attempted to instantiate admin view xxx without default view #2125

Open Tambura opened 3 years ago

Tambura commented 3 years ago

The view definition:

class AdminTagView(BaseView):
    @expose("/admin_tag")
    def index(self):
        return self.render("admin_tag.html")

Add view:

admin.add_view(AdminTagView(name="AdminTag", endpoint="admin_tag"))

Why I get the error: Attempted to instantiate admin view AdminTagView without default view

eos68 commented 2 years ago

You'll have to expose to the root: @expose('/')

carter3689 commented 10 months ago

Hi,

I'm recently experiencing a similar error. WIth the understanding that the / root has to be used...what would I use in the case were I needed the url to have a variable at the end. For example /<id>?

Acrofil commented 3 months ago

Hi i have a similar issue or something in my approach is not right.. i will try to explain what i want to achieve and hopefully someone will be able to assist me in the right direction.

I want to create a navbar menu category, where in that category the dropdown content is all entries from a given table. For example

class MyCustomView(BaseView):

    @expose
    def index(self, "/"):
        return self.render("my_index.html")

    @expose
    def show_entry_data(self, "/show_entry_data/<int:entry_id>"):

    my_entry = Entry.query.filter_by(id=entry_id).first()
    return self.render("show_entry_data.html, entry=my_entry)`

cars = Cars.query.all()

for car in cars:
   admin.add_view(MyCustomView(name=car.name, category="Cars", url="/show_entry_data/{car.id}")

For some reason i fail to achieve what i want. Is this the proper way of doing it?