Question: I want to create a management page where an admin can delete users. I have succesfully made it list created users, but now i'm struggeling with how to create a deleteView to delete the user entirely from my django project.

Views.py

```
def index(request):
    users = User.objects.all()
    return render(request, 'EditUser.html',{'userlist':users})

def deletefunction(request,User =None):
    object = User.objects.get(id=User)
    object.delete()
    return render(request,'EditUser.html')

```

Project urls.py

```
from edit_user.views import deletefunction

urlpatterns = [
    path('admin/', admin.site.urls),
    path('management', include('management.urls')),
    path('management/create', include('signup.urls')),
    path('management/edit', include('edit_user.urls')),
    path('^delete/(?P<User>[0-9]+)/$', deletefunction, name='delete_view'),
]

```

HTML code 

```
<div class="container">
          {% for item in userlist %} 
          <tr> 
              <td>{{ item.username }}</td><a href="{% url 'EditUser:deletefunction' User %}">delete</a> 
          </tr>  
          {% endfor %} 

          </div>

```

As of right now when i'm trying to load my page i'm receiving this exception. 

> 
> Reverse for 'deletefunction' not found. 'deletefunction' is not a
>  valid view function or pattern name.
> 
> 
>

Answer: 
You're comparing a String **object** with a **primitive** string. Those are two different types.

To make it clearer, here are [all JS types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures):

> 
> * Six data types that are primitives:
> 	+ Boolean
> 	+ Null
> 	+ Undefined
> 	+ Number
> 	+ String
> 	+ Symbol (new in ECMAScript 6)
> * and Object
> 
> 
> 

When compared using `===`, an object is only equal to itself (and thus not to a primitive value nor to another identical object)

When comparing using `==`, EcmaScript follows [this procedure](https://www.ecma-international.org/ecma-262/9.0/index.html#sec-abstract-equality-comparison), which calls the `toString` method on the String object.

There's normally no reason to explicitly use String objects (you implicitly use them every time your code needs an object and you pass a string, but the JS engine handles the promotion for you). You should almost always stick to primitive strings.
Because 

```
typeof new String('Hello') === 'object'

```

and 

```
typeof 'Hello' === 'string'

```

The former is an object, the latter is a primitive.

The `==` check works because the `String` object has also `toString` method and JS invokes that method in this case (as well as when concatenating with other string).