1
I have a table with users in HTML with id and name, by default when register a person it comes with is_staff=False.
I want when I click the Authorize link to switch to is_staff=True, how do I do this in the view?
 {% block content %}
         <p>Usuários</p>
        <table class="striped" id="cadastrados">
        <thead>
          <tr>
              <th>Código</th>
              <th>Nome</th>
              <th>Telefone</th>
              <th>Ramal</th>
              <th>É staff?</th>
              <th>Autorizar</th>
          </tr>
        </thead>
            <tbody>
          {% for item in lista_usuarios %}
             <tr>
              <td>{{ item.id }}</td>
                <td>{{ item.first_name }}</td>
                 <td>{{ item.telefone }}</td>
                  <td>{{ item.ramal }}</td>
                  <td> {{ item.is_staff }} </td>
                  <td> <a href="{% url 'cadastro:autorizar' %}"></a>  <a class="btn-floating btn-large red">
                        <i class="large material-icons">mode_edit</i></a> </td>
             </tr>
          {% endfor %}
       </tbody>
        </table>
        {% endblock content %}
py views.
def quantities(request, value=None):
    if value == "2":
        usuarios = Perfil.objects.filter(is_staff=False)
        context = {'lista_usuarios': usuarios}
    else:
        usuarios = Perfil.objects.filter(is_staff=True)
        context = {'lista_usuarios': usuarios}
    return render(request, 'quantities.html', context)
						
Thank you, very practical the way you showed me, when I inspect the page every authorize button is getting the right id, but when I click nothing happens
– Bianca C.
Well there are several ways to test and identify the error. One of them (and the simplest) would be to put the url in the browser: localhost:8000/register/update/5 (if you are in a local environment) and see the error it will return. Remember to keep an eye on the Django console.
– mcmartin
When I access the url it returns the name of the person, that is to say it is picking up, right? only the href link that is not working even
– Bianca C.
When you click on the link appears what? the page url changes? It may be useful to open another ask and post a print.
– mcmartin
Nothing happens like there’s no link
– Bianca C.
seems a simple mistake in href
– mcmartin
I did, it was the <a> closing in the wrong place, it was like this: <a href="{% url 'register:authorize' item.id %}" class="btn-floating btn-large red"> <i class="large material-icons">mode_edit</i> </a>
– Bianca C.