0
Is there a Django function that concatenates a specific path with the base URL and returns a full URL?
Example:
url_completa = criar_url_completa("/meu_app/minha_view")
print(url_completa) # Resultado: https://meusite.com/meu_app/minha_view
0
Is there a Django function that concatenates a specific path with the base URL and returns a full URL?
Example:
url_completa = criar_url_completa("/meu_app/minha_view")
print(url_completa) # Resultado: https://meusite.com/meu_app/minha_view
0
In Settings.py has a field called ALLOWED_HOSTS, it can be placed the site address in various forms.
EX: ALLOWED_HOSTS = ['https://meusite.com' , 'meusite.com']
Then go to your view where you want to get your base url and import the Settings:
from django.conf import settings
url_completa = criar_url_completa("{}/meu_app/minha_view".format(ALLOWED_HOSTS[0])
print(url_completa) # Resultado: https://meusite.com/meu_app/minha_view
Browser other questions tagged python django
You are not signed in. Login or sign up in order to post.
Behold
HttpRequest.build_absolute_uri(location=None)
– Augusto Vasques
That helped yes thank you
– J. Igor