'How to disable "django login" hyperlink while accessing swagger ui in drf-yasg?

I'm using drf-yasg to add swagger auto schema to my endpoints. The swagger-ui is being visible at /api/v1/swagger/ At my local setup this link is working fine and I'm getting the proper schema as required.

/api/v1/swagger at my local setup

But while accessing the same link when my application is deployed at the server, It is showing a "django login" hyperlink as:

/api/v1/swagger at server

And this "django login" hyperlink is navigating to -> SERVER_IP/accounts/login/?next=/api/v1/swagger/ which is showing 404 Not found page as: 404 Not found page after clicking on django login hyperlink

Even though the openAPI yaml file is being successfully generated of the endpoints at server, but the UI is not getting visible.

There was one similar question at stackoverflow: Similar question at SO, but the solution mentioned there was not working for me.

Thanks.



Solution 1:[1]

May you need to set USE_SESSION_AUTH to False in SWAGGER_SETTINGS in settings.py file.

# Swagger settings
SWAGGER_SETTINGS = {
    'USE_SESSION_AUTH': False        
}

Hope it could help.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Lu