# Page Not Found after much searching

**URL:** <https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611>\
**Category:** Forms & APIs\
**Created:** [August 26, 2022, 12:35am UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611 "2022-08-26T00:35:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mfones](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mfones/32/5034_2.png) [@mfones](https://forum.djangoproject.com/u/mfones)\
**Post date:** [August 26, 2022, 12:35am UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/1 "2022-08-26T00:35:51Z")

</div>

Need another set of eyes on this. I’m getting a 404 and I can’t find the reason.  
HTML

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/6/6e8211141552668241826749e60fccbcc4654dc0.png)

urlPatterns

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/a/a41e092c219f090ba35178e563f7ca2876a750db.png)

View

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/2/263551fee40174a2ca2ca6cfb34c5f322367a94d.png)

Error

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/f/fe27aff332bb86ee762eb696cffdce0f8c2a2066.png)

Can anyone see an error?

---

<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:** [August 26, 2022, 12:48am UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/2 "2022-08-26T00:48:41Z")

</div>

Yes, the url is expecting a parameter. You’re trying to access the _name_ of the url as if it were the url. The actual url is of the form `'tryoutRosters/<tryoutRoster_id>'`, which means your request would need to be of the form `http://localhost:8000/tryoutRosters/15`.

---

<div class="post-metadata">

**Author:** ![mfones](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mfones/32/5034_2.png) [@mfones](https://forum.djangoproject.com/u/mfones)\
**Post date:** [August 28, 2022, 2:23pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/3 "2022-08-28T14:23:31Z")

</div>

Still can’t find it. I have a similar part of my site that works like what I’m trying to do with updateRoster. I listed the code back to back for comparison. Does anything jump out at you from these code snippets?

```auto
{% url 'updateTryoutRoster' tryoutRoster.id %}
{% url 'show_player' player.id %}

path('show_player/<player_id>', views.show_player, name='show_player'),
path('updateTryoutRoster/<tryoutRoster_id>', views.updateTryoutRoster, name='updateTryoutRoster'),

<a href="{% url 'show_player' player.id %}" type="button" class="btn btn-dark btn-sm">View/Update</a>
<a href="{% url 'updateTryoutRoster' tryoutRoster.id %}" type="button" class="btn btn-dark btn-sm">View/Update</a>

```

I get a NoReversMatch error when I add `"{% url 'updateTryoutRoster' tryoutRoster.id %}"` to the HTML. For what its worth, there is no error when I leave the link blank:

```auto
<a href="" type="button" class="btn btn-dark btn-sm">View/Update</a>

```

```auto
NoReverseMatch at /tryoutRosters/
Reverse for 'updateTryoutRoster' with arguments '('',)' not found. 1 pattern(s) tried: ['updateTryoutRoster/(?P<tryoutRoster_id>[^/]+)$']
Request Method:	GET
Request URL:	http://localhost:8000/tryoutRosters/
Django Version:	3.1.7
Exception Type:	NoReverseMatch
Exception Value:	
Reverse for 'updateTryoutRoster' with arguments '('',)' not found. 1 pattern(s) tried: ['updateTryoutRoster/(?P<tryoutRoster_id>[^/]+)$']
Exception Location:	G:\Projects\Django\MealAppContainer\venv\lib\site-packages\django\urls\resolvers.py, line 685, in _reverse_with_prefix
Python Executable:	G:\Projects\Django\MealAppContainer\venv\Scripts\python.exe
Python Version:	3.9.1
Python Path:	
['G:\\Projects\\Django\\MealAppContainer\\mealapp',
 'C:\\Python39\\python39.zip',
 'C:\\Python39\\DLLs',
 'C:\\Python39\\lib',
 'C:\\Python39',
 'G:\\Projects\\Django\\MealAppContainer\\venv',
 'G:\\Projects\\Django\\MealAppContainer\\venv\\lib\\site-packages']
Server time:	Sun, 28 Aug 2022 09:06:35 -0500

```

---

<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:** [August 28, 2022, 2:27pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/4 "2022-08-28T14:27:00Z")

</div>

Notice the error message:

> [@mfones](#):
>
> `Reverse for 'updateTryoutRoster' with arguments '('',)' not found.`

You have:

> [@mfones](#):
>
> `{% url 'updateTryoutRoster' tryoutRoster.id %}`

What this means is at the point you’re trying to render this url, your context either doesn’t have an entry named `tryoutRoster`, or the object named `tryoutRoster` doesn’t have an attribute named `id`.

---

<div class="post-metadata">

**Author:** ![mfones](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mfones/32/5034_2.png) [@mfones](https://forum.djangoproject.com/u/mfones)\
**Post date:** [August 28, 2022, 2:46pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/5 "2022-08-28T14:46:46Z")

</div>

Here’s screen shot of the database.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/2/21ba0d6c189cd3bcdff0db8a2e140108983fbf6b.png)  
There is one record in it and its id=5, its the primary key, I believe. I believe that unless you specify otherwise, Django creates a PK and assigns the attribute ‘id’ to it, correct?

---

<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:** [August 28, 2022, 2:48pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/6 "2022-08-28T14:48:07Z")

</div>

That is correct.

This doesn’t have anything to do with your model.

What are you passing to your template in your context? Are you passing something called `tryoutRoster`?

---

<div class="post-metadata">

**Author:** ![mfones](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mfones/32/5034_2.png) [@mfones](https://forum.djangoproject.com/u/mfones)\
**Post date:** [August 28, 2022, 2:50pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/7 "2022-08-28T14:50:52Z")

</div>

Items commented out for troubleshooting.

```auto
def updateTryoutRoster(request, tryoutRoster_id):
  tryoutRoster = TryoutRoster.objects.get(pk=tryoutRoster_id)
  print(tryoutRoster)
  # form = TryoutRosterForm(request.POST or None, instance=TryoutRoster)
  # if form.is_valid():
  # form.save()
    # return redirect('camp_roster')
  return render(
    request, 'tryouts/updateTryout_Roster.html',
    {'tryoutRoster': tryoutRoster,})
    # 'form': form})

```

---

<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:** [August 28, 2022, 2:53pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/8 "2022-08-28T14:53:35Z")

</div>

And what are you getting as a result of this test?

- What is being printed as a result of your print statement?
- What does your `updateTryout_Roster.html` look like?  
(Note: If you’re still getting the same error (NoReverseMatch) with this, we’ll need to see the _entire_ template.)

Note: Are you sure we’re looking at the right view here? It seems to me that the problem is actually in the view that is supposed to take you to this page. It appears from your earlier post that you’re trying to generate a url for this view.

---

<div class="post-metadata">

**Author:** ![mfones](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mfones/32/5034_2.png) [@mfones](https://forum.djangoproject.com/u/mfones)\
**Post date:** [August 28, 2022, 3:02pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/9 "2022-08-28T15:02:34Z")

</div>

> - What is being printed as a result of your print statement?

Nothing prints, the page won’t load, the error is what I see.

> - What does your `updateTryout_Roster.html` look like?

Commented out the tryoutRoster for testing. Commenting in or out, no impact.

```auto
{% extends 'mealapp/base.html' %}
{% block content %}
<br>
<br>
<br>
<br>

<h1>Update Roster</h1>
  
  <!-- {{ tryoutRoster }} -->

<br/>
{% endblock %}

```

> (Note: If you’re still getting the same error (NoReverseMatch) with this, we’ll need to see the _entire_ template.)

What do you mean entire template?

---

<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:** [August 28, 2022, 3:07pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/10 "2022-08-28T15:07:24Z")

</div>

This was a late edit to my earlier post - copying it here in case you missed it.

> [@KenWhitesell](#):
>
> Note: Are you sure we’re looking at the right view here? It seems to me that the problem is actually in the view that is supposed to take you to this page. It appears from your earlier post that you’re trying to generate a url for this view.

> [@mfones](#):
>
> Nothing prints, the page won’t load, the error is what I see.

So the problem is _not_ in _this_ view - the problem is in the view that is supposed to send you to this view.

We need to look at the view that is causing the error.

---

<div class="post-metadata">

**Author:** ![mfones](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mfones/32/5034_2.png) [@mfones](https://forum.djangoproject.com/u/mfones)\
**Post date:** [August 28, 2022, 3:15pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/11 "2022-08-28T15:15:07Z")

</div>

Modeled from an other section I’ve created that works…  
I am trying to create a button in a list of rosters that takes the user to the roster to edit it. Below is the view of the roster list.

```auto
def tryoutRoster(request):
  roster_list = TryoutRoster.objects.all()
  # order_by('lastName')
  
  return render(request, 'tryouts/tryoutRosters.html', 
  {
  'roster_list': roster_list,
  # 'total_forwards': total_forwards,
  # 'total_goaltenders': total_goaltenders,
  })

```

This view is working and displays the page, but the trouble comes when I start adding the link in the HTML adding the button

```auto
{% extends 'mealapp/base.html' %}
{% block content %}
<br>
<br>
<br>
<br>
<br/>

<div class="container mt-4">
  <div class="shadow p-4 mb-5 bg-body rounded">
    <h1>Rosters ({{ total_players }})</h1>
    <div class="container">
    </div>
    <table class="table table-hover table-sm">
      <thead>
        <tr class="table-dark">
          <th scope="col">Roster Name</th>
          <!-- <th scope="col">First Name</th> -->
          <th scope="col">Event Code</th>
          <!-- <th scope="col">Released</th> -->
          <!-- <th scope="col">Date Released</th> -->
          <th scope="col">Roster Info</th>
          <th scope="col"></th>
        </tr>
      </thead>
      <tbody">
        <tr>
          {% for roster in roster_list %}
          <td>{{ roster.tryoutRoster }}</td>
          <td>{{ roster.tryoutDate }}</td>
          <td>
          </td>
          <td>
            <a href="{% url 'updateTryoutRoster' tryoutRoster.id %}" type="button" class="btn btn-dark btn-sm">View/Update</a>
          </td>
        </tr>
      </tbody>
      {% endfor %}
    </table>
  </div>
  </div>

{% endblock %}

```

---

<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:** [August 28, 2022, 3:23pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/12 "2022-08-28T15:23:13Z")

</div>

Ok, so where in that context are you supplying something called `tryoutRoster`?

---

<div class="post-metadata">

**Author:** ![mfones](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mfones/32/5034_2.png) [@mfones](https://forum.djangoproject.com/u/mfones)\
**Post date:** [August 28, 2022, 3:43pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/13 "2022-08-28T15:43:39Z")

</div>

I don’t follow. updateTryoutRoster is the view function that searches for the tryoutRoster\_id passed to it from the page. The tryoutRoster\_id is returned and the update\_Tryouts page opens.  
I guess I don’t understand the function of returning context dictionary variable tryoutRoster. It contains the id, what do I do with it in order to open the page that will allow editing of that id?

---

<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:** [August 28, 2022, 4:05pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/14 "2022-08-28T16:05:40Z")

</div>

> [@mfones](#):
>
> updateTryoutRoster is the view function that searches for the tryoutRoster\_id passed to it from the page.

This has _nothing_ to do with the No Reverse Match error being discussed here. There is nothing in, or associated with, `updateTryoutRoster` that is relevant here. Focus _only_ on `tryoutRoster`.

The issue is _only_ concerned with your `tryoutRoster` view, and the URL it is trying to create to _access_ `updateTryoutRoster`.

You have a template being rendered in `tryoutRoster`.

This template has (in part):

> [@mfones](#):
>
> `<a href="{% url 'updateTryoutRoster' tryoutRoster.id %}" ...`

This means that the template rendering function is going to look for something named `tryoutRoster` in the current context. (This is the context being used to render _this_ template.) Once it retrieves the object referenced as `tryoutRoster`, the rendering engine will then try to access an attribute named `id` using the rules described at [Templates | Django documentation | Django](https://docs.djangoproject.com/en/4.1/topics/templates/#variables).

The issue is that in _this_ view, for _this_ template, you do not have anything in the context named `tryoutRoster`.

Edit: Follow-up question - _which_ id do you want used at that point in the template?

---

<div class="post-metadata">

**Author:** ![mfones](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mfones/32/5034_2.png) [@mfones](https://forum.djangoproject.com/u/mfones)\
**Post date:** [August 28, 2022, 6:29pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/15 "2022-08-28T18:29:05Z")

</div>

the id I want is the id of the selected roster.  
At the outside chance you might be available for a chat… I’m Discord member #3757. Totally understand if your not.

---

<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:** [August 28, 2022, 6:34pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/16 "2022-08-28T18:34:12Z")

</div>

> [@mfones](#):
>
> the id I want is the id of the selected roster.

You’re jumping ahead - nothing has been selected yet.

You’re trying to render a page with links.

It looks like you’re trying to render a number of links in that template. (You’re iterating over a list - actually a queryset.)

For each entry in that list, you’re rendering some data.

For any particular entry then, _which_ `id` field are you looking to use?

---

<div class="post-metadata">

**Author:** ![mfones](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mfones/32/5034_2.png) [@mfones](https://forum.djangoproject.com/u/mfones)\
**Post date:** [August 28, 2022, 6:59pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/17 "2022-08-28T18:59:27Z")

</div>

> For any particular entry then, _which_ `id` field are you looking to use?

the id of the tryoutRoster.  
Here’s the example of what I’ve done previously that works.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/2/2b662f0b7e02f37e01cb6980729d324617f6ec89.png)  
I want to do the same thing here. Note: this page only displays because I’ve removed the link in the HTML.

```auto
<a href="" type="button" class="btn btn-dark btn-sm">View/Update</a>

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/c/ca93466a0e036c7056729059f6beb41e56b3e40a.png)

---

<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:** [August 28, 2022, 7:00pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/18 "2022-08-28T19:00:51Z")

</div>

> [@mfones](#):
>
> the id of the tryoutRoster.

But _which_ tryout roster? Aren’t there many of them?

---

<div class="post-metadata">

**Author:** ![mfones](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mfones/32/5034_2.png) [@mfones](https://forum.djangoproject.com/u/mfones)\
**Post date:** [August 28, 2022, 7:03pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/19 "2022-08-28T19:03:25Z")

</div>

The button will be at the end of each roster in the list of rosters. The point is to be able to view any roster and make changes. There is only one roster in the list currently, just testing right now. Eventually there will be a dozen or so rosters. With the goal being many rosters in the regulars season. But those will be line ups after I get this working.

---

<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:** [August 28, 2022, 7:04pm UTC](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611/20 "2022-08-28T19:04:31Z")

</div>

For clarity, you had one image in your previous reply, now you’ve got two.

Which one of these two are we talking about here?

[Next page](https://forum.djangoproject.com/t/page-not-found-after-much-searching/15611.md?page=2)
