I want to save in a variable the url to access a service, so I am using reverse
and the name
for the entry in urlpatterns
, and I get something like /es/general/provider_types/
, but I want to get a full url, like https://127.0.0.1:8000/es/general/provider_types/
This is how I am using reverse
:
{'name': models.ProviderType._meta.verbose_name_plural.title(), 'url': reverse('rest_provider_types_list')}
Is there any way I can do this?
您可以使用request.build_absolute_uri()
方法返回绝对网址:
request.build_absolute_uri(reverse('rest_provider_types_list'))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.