PeterP
PeterP

Reputation: 45

Django: How can I include the output of one view in another?

When a user visits mysite.com/articles, they see I a lists several articles.

How can I include this list into another page, e.g. the home page, but so that I can still add extra content to the home page? This list of articles will only appear on those 2 pages, so a custom tag seems a bit like overkill.

Thanks

Upvotes: 1

Views: 274

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799470

Refactor the list of articles into a separate function, then call that function from both views.

But a custom tag really is the proper solution for this.

Upvotes: 2

Related Questions