7

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?

Paco
  • 4,292
  • 2
  • 28
  • 52
nam
  • 3,243
  • 9
  • 43
  • 64

1 Answers1

6

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

Doobeh
  • 8,890
  • 34
  • 30
  • If you're wondering what a flask endpoint is, check out this answer: http://stackoverflow.com/questions/19261833/what-is-an-endpoint-in-flask – d512 Jul 19 '16 at 20:30