print full_url = request.get_host()+request.get_full_path()
Result:
127.0.0.1:8000/test/en/
or
127.0.0.1:8000/test/ru/
How to check if the end of the string is /en/ or /ru/
print full_url = request.get_host()+request.get_full_path()
Result:
127.0.0.1:8000/test/en/
or
127.0.0.1:8000/test/ru/
How to check if the end of the string is /en/ or /ru/
Use endswith:
full_url.endswith('/en/') or full_url.endswith('/ru/')
If you find that there are more extensions you have to cover, you may consider using any:
any(s.endswith(ext) for ext in ['/ru/', '/en/'])
ru is not on the end of the string 127.0.0.1:8000/ru/test/?in, e.g. '/en/' in full_url or '/ru/' in full_url.any or or here: .endswith accepts a tuple. For example: full_url.endswith(('/en/','/ru/')).