0

I was modifying satchmo(a python online store project), but I found that I can't use [0, 5] to get the substring in the model. And I found the type is class 'django.utils.safestring.SafeUnicode' in django string processing.

Does class 'django.utils.safestring.SafeUnicode' support [0, 5] to get the substring as in python?

Bin Chen
  • 61,507
  • 53
  • 142
  • 183

1 Answers1

5

Slice it. http://docs.python.org/tutorial/introduction.html

>>> 'foobar'[0:5]
[Out] 'fooba'

Update: sure, why not?

>>> django.utils.safestring.SafeUnicode('foobar')[0:5]
[Out] 'fooba'
Yuji 'Tomita' Tomita
  • 115,817
  • 29
  • 282
  • 245