I found this to be useful if you need to know the port number or IP address from the view (e.g. in models.py).
import sys import socket logger.error(socket.gethostbyname(socket.gethostname())+"----"+sys.argv[-1])
This will give you the output as shown below:
192.168.1.222----0.0.0.0:8000
source share