In php's Codeigniter, the uri class ( https://www.codeigniter.com/user_guide/libraries/uri.html ) has the ability to retrieve a url segment using:
$this->uri->segment(n)
Is there an equivalent abilty in Django?
This is a part of the standard Python library, in the urlparse module.
import urlparse
path = urlparse.urlsplit(uri).path
print path.split('/')[n]
Codeigniter uses a segment-based approach which, by default, imposes url structured as follows: class/function/ID
.
Django lets you design URLs however you want, with no framework limitations so there is no need of a URL helper like the one in CI.
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.