djangosnippets.org: Latest snippets tagged with 'text'https://djangosnippets.org/tags/text/2017-01-25T01:52:31.834463-06:00replace
2017-01-25T01:52:31.834463-06:00atombrellahttps://djangosnippets.org/snippets/10602/<p>Small example of how to write your own function. This is not available in Django. The function just replaces static text strings, regular expressions are not supported.</p>
<p>The syntax is the same in SQLite, PostgreSQL, MySQL and Oracle.</p>
Freely redistributablehighlight text
2014-08-19T09:17:26.665808-05:00nathantnhttps://djangosnippets.org/snippets/3087/<p>How to use:</p>
<p>{% load highlight %}</p>
<p>{{ text|highlight:'word' }}</p>
Freely redistributableCompressedTextField for Django 1.4+
2013-02-15T10:32:25.505165-06:00devhuluhttps://djangosnippets.org/snippets/2893/<p>This snippet <em>updates</em> http://www.djangosnippets.org/snippets/383/ and http://www.djangosnippets.org/snippets/1495/ for Django 1.4+, and adds support for sqlite3 and south. Original snippet text: A CompressedTextField to transparently save data gzipped in the database and uncompress at retrieval.</p>
Freely redistributableFilter that adds a period at the end of a string
2013-01-15T14:59:11.240376-06:00Ztyxhttps://djangosnippets.org/snippets/2878/<p>Yeah, I know this is a very basic filter, but I thought I might as well share it with the world...</p>
Freely redistributabletxt2img tag to show on the web text as images
2012-04-29T06:53:27.600034-05:00br0th3rhttps://djangosnippets.org/snippets/2737/<p>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.</p>
<p>Usage:
<code>{{worker.email|txt2img:18|safe}}</code></p>
Freely redistributablemadslug
2011-08-24T17:36:23.772439-05:00catellarhttps://djangosnippets.org/snippets/2529/<p>this will turn</p>
<p>ikfjji34 iojwe# eijdf#@$iojdfg 234oijdfg</p>
<p>into</p>
<p>ikfjji_iojwe_eijdfiojdfg_oijdfg</p>
Freely redistributableUnlimited-length CharField
2011-01-19T03:33:48.718332-06:00rfuggerhttps://djangosnippets.org/snippets/2328/<p>Unlimited-length character fields in Postgres perform the same as limited-length fields, and the Postgres manual suggests not arbitrarily limiting these fields. Unfortunately, Django does not provide a way to access unlimited-length character fields except using TextField, which is rendered differently in forms and in the admin, and has different connotations. …</p>
Freely redistributableCompressedTextField
2010-05-08T10:21:31.312407-05:00Digitalxerohttps://djangosnippets.org/snippets/2014/<p>I found my self doing data migration for a client, and also found that their old system (CSV) had 4 text fields that were 2 to 4MB each and after about 2 minutes of hammering the mysql server as I was parsing this and trying to insert the data the …</p>
Freely redistributableText replacement with alternative font faces
2009-06-21T12:51:15.443445-05:00scsiboyhttps://djangosnippets.org/snippets/1583/<p>Complex of tags and filters for easy replacement of text with alternative font faces. For browsers, who doesn`t support it by themselves.</p>
<p>Templatetag code and documentation at <a href="http://github.com/SkAZi/django-headline">GitHub of django-headline</a>.</p>
Freely redistributableCompressedTextField for Django 1.0+
2009-05-07T09:31:32.373992-05:00bwhittingtonhttps://djangosnippets.org/snippets/1495/<p>This snippet updates http://www.djangosnippets.org/snippets/383/ for Django 1.0+, and adds support for sqlite3.
Original snippet text:
A CompressedTextField to transparently save data gzipped in the database and uncompress at retrieval.</p>
Freely redistributableSoft hyphenation (&shy;) template filter using PyHyphen
2009-04-16T19:10:01.335684-05:00dokterbobhttps://djangosnippets.org/snippets/1446/<p>This template filter is meant to insert soft hyphens (<a href="http://www.cs.tut.fi/~jkorpela/shy.html">&shy; entities</a>) in text whever it can. For this is relies on a <strong>recent</strong> checkout of the <a href="http://code.google.com/p/pyhyphen/">PyHyphen</a> interface to the hyphen-2.3 C library, which is also used by Mozilla and OpenOffice.org.</p>
<p>It takes two optional parameters: the language …</p>
Freely redistributableText Highlighting Filter
2008-12-10T15:32:20.857191-06:00girasquidhttps://djangosnippets.org/snippets/1242/<p>This filter can be used to wrap <span class='highlight'> around anything you want to highlight in a block of text. For example, if you had 'foo bar foo baz' inside the context variable MYTEXT, you could do {{ MYTEXT|highlight:'foo' }}, and "<span class='highlight'>foo</span> bar <span class='highlight'>foo</span> baz" would be returned. …</p>
Freely redistributableSnippySnip
2008-07-17T20:29:50.432992-05:00youellhttps://djangosnippets.org/snippets/891/<p><strong> Help me get better! If you vote (either way) please leave a comment if you have time and say what was good or bad. I appreciate any and all feedback. Thanks! </strong></p>
<p>I keep finding places in my apps where I need an isolated snippet of text that can periodically be …</p>
Freely redistributableMySQL "Text" Type Model Field
2008-05-27T16:33:45.612991-05:00blackbrrrhttps://djangosnippets.org/snippets/775/<p>Custom field for using MySQL's <code>text</code> type. </p>
<p><code>text</code> is more compact than the <code>longtext</code> field that Django assigns for <code>models.TextField</code> (2^16 vs. 2^32, respectively)</p>
Freely redistributableoracle 10g fulltext search & patch nclob field limitations
2008-04-05T02:59:10.828795-05:00ageldamahttps://djangosnippets.org/snippets/685/<p>save as some module,
import then, call 'patch()' in somewhere suchs urls.py...</p>
Freely redistributable