在Django中,我需要path converter中的to_url(self, value)
方法做什么?你知道吗
我在公文上只能找到几个例子,不明白这种方法的用法。你知道吗
tou url()到底做什么?你知道吗
class FourDigitYearConverter:
regex = '[0-9]{4}'
def to_python(self, value):
return int(value)
def to_url(self, value):
return '%04d' % value
Tags:
此方法将值(例如本例中的数字)转换为可在URL中使用的字符串(例如,如果值是整数(例如4)),则将其格式化为“0004”。你知道吗
相关问题 更多 >
编程相关推荐