# How can I have a same view for all pages/template

**URL:** <https://forum.djangoproject.com/t/how-can-i-have-a-same-view-for-all-pages-template/15031>\
**Category:** Getting Started\
**Created:** [July 25, 2022, 6:50pm UTC](https://forum.djangoproject.com/t/how-can-i-have-a-same-view-for-all-pages-template/15031 "2022-07-25T18:50:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pierrot10](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/pierrot10/32/9107_2.png) [@pierrot10](https://forum.djangoproject.com/u/pierrot10)\
**Post date:** [July 25, 2022, 6:50pm UTC](https://forum.djangoproject.com/t/how-can-i-have-a-same-view-for-all-pages-template/15031/1 "2022-07-25T18:50:30Z")

</div>

Hello

I am starting with Django and I understand I can apply a view with a template and target a link to a view.

If I have a simple web site with 5 pages, I could create a view for each page.  
Actually I have a base.html template and my 5 pages have a view whoch import the base.html template  
I have an application which use weather station in several fields. All of this devises are save into a database. Then I can extract the information of the fields.

I would like to know, how can I create a view, which queries the fields from my MySQL database and show the result in all pages, as a menu?

Is there a dedicated view which can be applied to all templates, as I could do for a menu?

Thanks

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 25, 2022, 7:11pm UTC](https://forum.djangoproject.com/t/how-can-i-have-a-same-view-for-all-pages-template/15031/2 "2022-07-25T19:11:40Z")

</div>

A url is defined to be mapped to a view.

A view receives the request to that URL and returns a response.

How that view determines what that response should look like is entirely up to you.

Is there a “dedicated view” for this? Yes, you can build this by extending TemplateView or DetailView.

---

<div class="post-metadata">

**Author:** ![Rigo-Villalta](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/rigo-villalta/32/5667_2.png) [@Rigo-Villalta](https://forum.djangoproject.com/u/Rigo-Villalta)\
**Post date:** [July 25, 2022, 7:11pm UTC](https://forum.djangoproject.com/t/how-can-i-have-a-same-view-for-all-pages-template/15031/3 "2022-07-25T19:11:56Z")

</div>

You have to add to the context of your view the results of the queryset . If you will use it in all the views of the site you should use a context processo
