HTML Hex Color Field
A custom form field than validates html hex color fields
- fields
- forms
- color
- hex
A custom form field than validates html hex color fields
Create a list containing an arithmetic progression that can be iterated through in templates. Emulate the [range](http://docs.python.org/library/functions.html#range) syntax. You can use either numbers or variables. Syntax: {% num_range [start] stop [step] as some_range %} {% for i in some_range %} ... do something {% endfor %} **About the author**: Take a look at [my website](http://www.marcofucci.com)
A template filter which returns "a" or "an" depending on the phonetic value of given text.
The {% url %} templatetag is awesome sometimes it is useful to get the full blown URL with the domain name - for instance for links in emails. The **{% absurl %}** templatetag mirrors the behaviour of {% url %} but inserts absolute URLs with the domain of the current Site object. Usage: {% absurl viewname %} >>> http://www.example.org/my/view/
This template tag was built to be used in web applications that are permission based. It renders the html for an html link tag if the user has permissions to access the view (if not, returns an empty string). It also checks if the current token is the active url address and, if so, adds class="active" to the html link for presentation purposes. Example usage: 1. {% url home as home_url %} {% get_link_if_allowed home_url "Home" %} 2. {% url project_dashboard project.id as project_dashboard_url %} {% get_link_if_allowed project_dashboard_url "Projects" %}
This is a custom template filter that allows you to truncate a string to a maximum of num characters, but respecting word boundaries. So, for example, if `string = "This is a test string."`, then `{{ string|truncatechars:12 }}` would give you "This is a..." instead of "This is a te".
For most applications, simplejson.dumps() is enough. But I’m especially fond of iterators, generators, functors (objects with a `__call__()` method) and closures, dense components that express one thought well: the structure of a tree, or the rows of a database, to be sent to the browser. The routine dumps() doesn’t understand any of those things, but with a simple addition, you can plug them into your code and be on your way without headache. Dumps() just calls JSONEncoder(), and JSONEncoder has a routine for extending its functionality. The routine is to override a method named default() (why “default?” I have no idea) and add the object types and signatures you want to send to the browser. Normally, this exists for you to provide custom “object to JSON” handlers for your objects, but there’s nothing custom about iterators, generators, functors and closures. They are native Python objects. This snippet provides the functionality needed by JSONEncoder to correctly dereference these useful Python objects and render their contents. (Originally posted [here](http://www.elfsternberg.com/2009/05/20/fixing-an-omission-from-djangos-simplejson-iterators-generators-functors-and-closures/) )
This is an extended version of the FormWizard which allows display of multiple forms per step and allows usage of ModelForms with initial objects
Getting a new ID according to the content type.
VAT field with a field to select the country and a free field for the code
I wanted a way to make columns but have them in floated uls...
I was in need to have pluggable components that all have more or less some media files. I didn't want to pollute my config with dozens of media paths so I wrote this custom command that copies contents `<appdir>/app_media` to your `MEDIA_ROOT/<appname>` path. In template you will refer your media files like `{{MEDIA_URL}}/appname/<path to media>`
This works with `Django 1.0.0` and later. It sets the `request.urlconf` variable to an alternate urlconf, if there's a match to the hostname in `settings.MULTIHOST_URLCONF_MAP`
A python implementation of the old MySQL PASSWORD() function. This is insecure. There is a reason MySQL changed this in version 4.1. Use it only if you have to!
This is a simple way to embed images in emails, rather than use absolute links, which many clients will not show by default. It has not undergone extensive testing but it should get you started. Comments / suggestions welcome.
3109 snippets posted so far.