Q:

Using a decorator with Django blocks the request

I'm trying to create my own decorator in order to validate a REST call with Django (using Django Rest Framework). 
The decorator looks like this:
def allowed_states(allowed=[]):
    def decorator(func):
        def wrapper(self, request, *args, **kwargs):
            print(func)
            result = func(self, request, *args, **kwargs)
            return result
        return wrapper
    return decorator

The request API looks something like this:
@swagger_auto_schema(
    operation_id="my_api",
    responses={
        status. HTTP_204_NO_CONTENT: "",
    }
)
@action(detail=True, methods=["DELETE"])
@allowed_states(allowed=["state1", "state2"])
def my_api(self, request, *args, **kwargs):
    # do some stuff here

When my @allowed_states decorator is removed, the call works just fine.  When I add it back I get a 404 error from Django framework saying it could not find a url pattern to execute for this call. 
I tried removing self from wrapper (and from the func invoke as well). 
Also I tried changing the decorators order above the function call. 
Both didn't work. 
The stack trace doesn't say much, merely that django could not find the url pattern:
 Using the URLconf defined in 
                <code>my_project.urls</code>,
      Django tried these URL patterns, in this order:

(and then the order of url patterns as they appear in my_project.urls)

A:

Following a suggestion in the comments I used functools.wraps and that solved the problem:
from functools import wraps

def allowed_states(allowed=[]):
    def decorator(func):
        @wraps(func)
        def wrapper(self, request, *args, **kwargs):
            print(func)
            result = func(self, request, *args, **kwargs)
            return result
        return wrapper
    return decorator

