(func)
return _wrapper_
Ensure uid passed to view function exists.
Ensure uid passed to view function exists.
Ensure uid passed to view function exists .
def post_exists(func):
    """
    Ensure uid passed to view function exists.
    """

    @wraps(func)
    def _wrapper_(request, **kwargs):
        uid = kwargs.get('uid')
        post = Post.objects.filter(uid=uid).exists()
        if not post:
            messages.error(request, "Post does not exist.")
            return redirect(reverse("post_list"))
        return func(request, **kwargs)

    return _wrapper_
def post_exists ( func ) : @ wraps ( func ) def _wrapper_ ( request , * * kwargs ) : uid = kwargs . get ( 'uid' ) post = Post . objects . filter ( uid = uid ) . exists ( ) if not post : messages . error ( request , "Post does not exist." ) return redirect ( reverse ( "post_list" ) ) return func ( request , * * kwargs ) return _wrapper_