Is there any way to find out what port a Django instance is listening on from within the code?
You can get the info through the HttpRequest. Checkout the Django Docs here.
This can be accessed through the META attribute which is a dictionary containing the HTTP header info.
Example:
def someView(request):
#Try printing to screen
print request.META['SERVER_PORT']
...
return(response)
maybe request.META['SERVER_PORT']
or are you not in a view?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With