When i run the server it shows me a message http://127.0.0.1:8000/. I want to get the url in code. I dont have request object there.
To check the current nameservers (DNS) for any domain name from a Linux or Unix/macOS command line: Open the Terminal application. Type host -t ns domain-name-com-here to print the current DNS servers of a domain. Another options is to run dig ns your-domain-name command.
Run the following command to start the Django server. Execute the following URL from the browser to display the domain name of the current URL. The geturl1() function will be called for this URL that will send the domain name to the index. html file.
request.build_absolute_uri('/')
or you could try
import socket socket.gethostbyname(socket.gethostname())
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