Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Django 有逆向方法django.core.urlresolvers.reverse()吗?
django.core.urlresolvers.reverse()
我想要一个f(x)这样的功能f(django.core.urlresolvers.reverse('shadowfax')) == 'shadowfax'。
f(x)
f(django.core.urlresolvers.reverse('shadowfax')) == 'shadowfax'
有人对这是否是为调用的方法编写单元测试的正确方法有什么要说的.reverse()吗?
.reverse()
大概是震惊:
django.core.urlresolvers.resolve( "/test" ).url_name
这是使用它的完美方式,甚至在文档中推荐:
https://docs.djangoproject.com/en/dev/ref/urlresolvers/