How to use model views in other apps

Don’t think of page construction in terms of your templates.

Your views are building your pages. The templates are just some text used by the view for producing those pages. It’s the view that accepts the request from the browser and returns a response.

What your templates look like is almost irrelevant. What matters are the views, and the context that those views create to use when rendering your templates.

Or, another way to say this is that you should be thinking that your “pages” are your views. The views (generally) fetch data from the database, pass that data (the context) to the rendering engine. The rendering engine builds some text from a template and the context, and returns it to the view. The view then sends that data back out to the browser. (That data could be html. It could also be JSON, XML, or even something else.)

All this comes around to saying that we need to see the views here.

1 Like