1

I am using flask app builder. Currently I am using the following code to access the view.

appbuilder.add_view(ItemView, "Item")

By default, it redirects me to listing page. And I know I can change the behaviour by overriding default_view.

But I am looking something as the following.

appbuilder.add_link("Add New Item", ItemView().get_add_link())

appbuilder.add_link("List Items", ItemView().get_list_link())

How to get the view URL of the list/add pages of the view?

oz123
  • 27,559
  • 27
  • 125
  • 187
ndemir
  • 1,881
  • 3
  • 19
  • 25
  • are you using vanilla flask or are you using flask-appbuilder? – oz123 Dec 21 '15 at 08:59
  • @Oz123, I forgot to mention it. I am using flask app builder. – ndemir Dec 21 '15 at 09:04
  • Well, I am not familiar with it, but I added a tag, it might help lure users and focus your potential helpers. Also, it might help if you reveal a bit of more code of your application, so people might know where to look. – oz123 Dec 21 '15 at 09:07

1 Answers1

0

You can't get it at that point since you don't have app context, with context you could use Flask url_for('ItemView.add').

On this case just use relative URL path:

appbuilder.add_link("Add New Item", href='/itemview/add')

dpgaspar
  • 1,193
  • 8
  • 10