Login

Tag "convert"

Snippet List

txt2img tag to show on the web text as images

txt2img tag shows on the web text as images, helping to avoid get indexed email address and some other information you don't want to be on search engines. Usage: `{{worker.email|txt2img:18|safe}}`

  • tag
  • text
  • image
  • templatetag
  • hide
  • convert
Read More

datetime.time/datetime.datetime to Unix Epoch (with microsecond support)

This is useful when you need to convert a datetime.datetime.now() or datetime.date.today() into a unix epoch seconds, with microsecond precision (precision only applies to datetime.datetime, as datetime.date won't have any microseconds). I have found this is necessary for when storing the DateTime in the models as a FloatField, in order to keep the usec/microsecond precision. At some point, I will probably create a custom model field called DateTimeWithUSec or something like that, but for now, this will do :)

  • datetime
  • date
  • time
  • epoch
  • convert
  • unix
  • usec
  • precision
  • microsecond
Read More

django-pyodbc MoneyField

This is a very small, simple piece of code, but essential for using fields of type 'money' on MS SQL Server, through FreeTDS. This took me quite some time to hunt down, as get_placeholder() is in fact an undocumented feature. **Example:** class MyModel(models.Model): price = MoneyField()

  • money
  • convert
  • pyodbc
  • django-pyodbc
Read More

Convert numbers in USA notation to brazilian notation

**This is the converter, just put it as a filter and call it with a float number.** * So, if you have a template variable **{{ my_number }}** that is "3096.44". * It will convert to "3.096,44" using the filter **{{ my_number|numBR }}**.

  • convert
  • float
  • usa
  • br
  • brazil
Read More

Convert Unicode to ASCII

Unicode is great, but there are places where the conversion ends up with unintelligible characters. I first noticed this with curly quotes entered in forms on our site. `unicode_to_ascii` converts compound characters to close approximations in ASCII: such as umlaut-u to u, 1/2 (fraction glyph) to 1/2. You can add additional mappings in CHAR_REPLACEMENTS.

  • unicode
  • ascii
  • convert
Read More

6 snippets posted so far.