8

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,520
  • 3
  • 29
  • 53
nam
  • 3,542
  • 9
  • 46
  • 68

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
  • 9,280
  • 39
  • 32
  • 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