python – Reverse for ‘user_edit’ not found. ‘user_edit’ is not a valid view function or pattern name


I’ve been stuck on this for a while, can’t seem to fix the error. I’ve checked the code a hundred times but obviously there is something I’m missing. I have installed my app also.

I created CRUD operations for User with 3 buttons: Details, Edit and Delete. The second 2 works exactly how it should be, but the first one ‘Details’ gives me this error: NoReverseMatch at /users/details/1
Reverse for ‘user_edit’ not found. ‘user_edit’ is not a valid view function or pattern name.
I’m trying to render user_details function, and I can’t find why gives me user_edit error message.

Can anybody see what I’m missing?

views.py

def user_details(request, id=None):
    context = {}
    context('user') = get_object_or_404(User, id=id)
    return render(request, 'userdetails.html', context)

def user_add(request):
    context = {}
    if request.method == 'POST':
        u = user_form = UserForm(request.POST)
        context('user_form') = user_form
        if user_form.is_valid():
            user_form.save()
            return HttpResponseRedirect(reverse('feedback:users'))
        else:
            return render(request, 'useradd.html', context)
    else:
        user_form = UserForm()
        context('user_form') = user_form
        return render(request, 'useradd.html', context)

def user_edit(request, id=None):
    context = {}
    user = get_object_or_404(User, id=id)
    if request.method == 'POST':
        user_form = UserForm(request.POST, instance=user)
        context('user_form') = user_form
        if user_form.is_valid():
            user_form.save()
            return HttpResponseRedirect(reverse('feedback:users'))
        else:
            return render(request, 'useredit.html', context)
    else:
        user_form = UserForm(instance=user)
        context('user_form') = user_form
        return render(request, 'useredit.html', context)

def user_delete(request, id=None):
    context = {}
    return render(request, 'userdelete.html', context)

urls.py

path('users/', views.users, name="users"),
path('users/add', views.user_add, name="useradd"),
path('users/details/<int:id>', views.user_details, name="userdetails"),
path('users/edit/<int:id>', views.user_edit, name="useredit"),
path('users/delete/<int:id>', views.user_delete, name="userdelete"),

users.html (basicaly my index page for the CRUD navigation)

{% extends 'main.html' %}

{% block content%}

    <h1>Users</h1>
    <a href="http://stackoverflow.com/users/add">Add user</a>
    <h2>List of {{title}} </h2>
    {% if users %}
        <ul>
            {% for user in users %}
                <li>
                    {{user.first_name}} &nbsp; {{user.last_name}}
                    <td class="text-center">
                        <a class="btn btn-primary float-center" href="{% url 'feedback:userdetails' user.id %}">Details</a>
                        <a class="btn btn-warning float-center" href="{% url 'feedback:useredit' user.id %}">Edit</a>
                        <a class="btn btn-danger float-center" href="{% url 'feedback:userdelete' user.id %}">Delete</a>
                    </td>
                </li>
            {% endfor %}
        </ul>
        {% else %}
            <p>There is no users available</p>
        {% endif %}
{% endblock content %}