I want to perform check and allow access to only specific pattern URLs and exclude few.
Using the following check to match for the allowed URLs
ALLOWED_URL = [
'/auth/*'
]
and using fnmatch to match the pattern
any(fnmatch(request.path, p) for p in settings.ALLOWED_URL)
This works for the following URL
/auth/login//auth/signup/google//auth/user-tracking/
But I want to exclude /auth/user-tracking/ from the URL and user should not access it. So I modified the pattern as
MULTI_USER_EXCLUDE_PATH = [
'/auth/[!user-tracking/*]*'
]
But this is now not working for
/auth/signup/google/
You can define a new
EXCLUDED_URLlist . Then, use thecheck_url_accessfunction to check if the request path starts with any of the paths inEXCLUDED_URLlist. If it does, the function returnsFalseto indicate that access is denied.