Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

About as_view function in Flask

The code in this example:

posts.add_url_rule('/', view_func=ListView.as_view('list'))
posts.add_url_rule('/<slug>/', view_func=DetailView.as_view('detail'))

I don't understand the parameter passed in the function as_view above, what is the purpose of listand detail here?

like image 418
nam Avatar asked Feb 26 '13 20:02

nam


1 Answers

It creates the endpoint for the routing system, so you can use url_for('posts.list') or similar, the API docs are here.

like image 138
Doobeh Avatar answered Sep 23 '22 19:09

Doobeh