# combining redirect and render ???

**URL:** <https://forum.djangoproject.com/t/combining-redirect-and-render/21068>\
**Category:** Forms & APIs\
**Created:** [May 21, 2023, 5:46pm UTC](https://forum.djangoproject.com/t/combining-redirect-and-render/21068 "2023-05-21T17:46:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [May 21, 2023, 5:46pm UTC](https://forum.djangoproject.com/t/combining-redirect-and-render/21068/1 "2023-05-21T17:46:19Z")

</div>

Hi, its me again, i was coping with my problem for a while on my own but right now i have to ask something to the helpful swarm-intelligence in here.  
i think i am not the first one with a similar question and i won’t be the last, but googeling it here or in StackOverflow didn’t really gave me a clue.

Description of problem is simple:

let`s say, i surf on the url-page “list-email.html” in my project. if a certain button is clicked, i want to switch to “show.html” with all its funcionlities. but doing

```auto
return render(request, 'show.html', context)

```

only gives me a proper view of the page with still list-email.html in the URL Bar of Browser and also lacks further functionalities of show.html…

Using redirect don’t gives me the content. There must be a simple solution for this???

---

<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:** [May 21, 2023, 5:52pm UTC](https://forum.djangoproject.com/t/combining-redirect-and-render/21068/2 "2023-05-21T17:52:45Z")

</div>

It all depends on what you mean by “button” here.

The archetypal answer is that the button should really be an `a` tag - a link to a different page. (You can format that tag to _look_ like a button, but not be one.)

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [May 22, 2023, 6:12am UTC](https://forum.djangoproject.com/t/combining-redirect-and-render/21068/3 "2023-05-22T06:12:41Z")

</div>

Hello again Ken,

so this is exactly what i thougt and tried. But wenn I test following template code on page “list-phone.html”, the button-submit event is properly done but afterwards i am still on “list-phone.html” in Browser and not on “show.html” ???

```auto
  <td>
      <button type="submit" name="id" value="{{ phone.id }}"
              class="btn-sm bg-transparent border border-0 rounded-1">
              <a href="{% url 'show' %}"><b>{{ phone.last_name }}</b></a>
      </button>
  </td>

```

and “show” in a is defined in urls.py like so:

```auto
path('show.html', views.show, name='show'),

```

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [May 22, 2023, 6:20am UTC](https://forum.djangoproject.com/t/combining-redirect-and-render/21068/4 "2023-05-22T06:20:03Z")

</div>

Never mind, after you encouraged me to search for solution in template, i put the target URL in the belonging form - action tag. now it works 🙂

```auto
<form method="post" target="_self" action="{% url 'show' %}">

```

---

<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:** [May 22, 2023, 11:52am UTC](https://forum.djangoproject.com/t/combining-redirect-and-render/21068/5 "2023-05-22T11:52:34Z")

</div>

Ahh - two things.

First, you never mentioned in your original post that a form was involved. Had I known that, we could have gotten to that solution directly.

Second, the reason the link you defined didn’t work was because it was still inside the button. If you had _just_ rendered the `a` tag by itself, and **not** within a `button` tag, that would have worked to send you to that other page. (It also would not submit the form you’re in, but that being necessary wasn’t known to me at the time.)

Anyway, glad to see you have it working!

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [May 29, 2023, 5:06pm UTC](https://forum.djangoproject.com/t/combining-redirect-and-render/21068/6 "2023-05-29T17:06:50Z")

</div>

Thx for your remarks, althouth i have read them much later…it is much worse than that…id had a form in a form-tag in my html file …but i am learning every day 🙂 Thx for your continuing advisory. I Appreciate it very much!
