Viewing posts for the category Django
Got this error running tests on a new project and couldn't figure out what the problem was. Found a similar problem with someone using Jenkins on SO who found the real error by running:
I've looked for a decent django blog platform for quite a while before finding Mezzanine a couple of months ago. I finally switched over my stack to Ubuntu upgraded to Django 1.4 and started running Mezzanine. So far, so good.
Converting a unicode string to a list of strings
http://stackoverflow.com/questions/5001385/unicode-to-python-object-conversion
n = [e.encode('utf-8') for e in s.strip('[]').split(',')]
If you've ever needed to save a variable spot in a Django template to be rendered later, there's special tags that allow you to do this:
I had a small piece of code I was using to parse a search string in Python for Sphinx. When you pass "verizon | mobile | at&t" to Sphinx (in boolean mode) it happily returns results. However, if you pass "verizon | mobile | at&t | " it throws an "unexpected $end near ''" error. So I needed to not add the extra pipe/or for the last element in my search string. Using split() to turn the string into a list and then using the [-1] index, you're able to determine if you're on the last element and not add the extraneous "or."