Human format Date representation
This template tag, takes the date format of the datetime object and returns the date in a human readable format.
- date
- humanize
This template tag, takes the date format of the datetime object and returns the date in a human readable format.
This template tag allows you to increment a variable within a template. This avoids the need of having to use the `add` filter and the syntax is quite intuitive.
Based on an answer here: <http://stackoverflow.com/a/6288863>
Converts an integer or floating-point number or a string to a string containing the delimiter character (default comma) after every delimeter_count digits (by default 3 digits)
This is a simple module for use with django to make a per user dropbox access simple Requirements: * standard django authentication * django sessions enabeled * dropbox python api >> easy_install dropbox To use this dropbox module you have to add the following configuration to your settings.py file `DROPBOX_SETTINGS = { 'app_key' : "insert key", 'app_secret' : "insert secret", 'type' : "app_folder", }` and of course to include it in INSTALLED_APPS `INSTALLED_APPS = ( ..., 'django_dropbox', )` to make a table to store personal access tokens for your users run >> python manage.py syncdb In your views you can import the dropbox_user_required decorator to mark views that should recive the named parameter dropbox_client ` from django_dropbox.decorator import dropbox_user_required @dropbox_user_required def myViewFunk(request, ..., dropbox_client): file = ... dropbox_client.put_file(file) `
This is useful if you have a string that is html encoded (i.e. "<p>Hello world!</p>") and you want to do something more complex than just display it as html, such as using the striptags filter.
Django allows you to specify your own ModelManager with custom methods. However, these methods are chainable. That is, if you have a method on your PersonManager caled men(), you can't do this: Person.objects.filter(birth_date__year=1978).men() Normally, this isn't a problem, however your app may be written to take advantage of the chainability of querysets. For example, you may have an API method which may return a filtered queryset. You would want to call with_counts() on an already filtered queryset. In order to overcome this, we want to override django's QuerySet class, and then make the Manager use this custom class. The only downside is that your functions will not be implemented on the manager itself, so you'd have to call `Person.objects.all().men()` instead of `Person.objects.men()`. To get around this you must also implement the methods on the Manager, which in turn call the custom QuerySet method.
Based on [#2020](http://djangosnippets.org/snippets/2020/) This snippet creates a simple generic export to csv action that you can specify the fields you want exported and the labels used in the header row for each field. It expands on #2020 by using list comprehensions instead of sets so that you also control the order of the fields as well.
Save attachment on couchdb document
This is a snippet for a simple CAPTCHA. A random image from a list of images is shown, and the form checks if the correct solution was given. Normally I would use django-simple-captcha or maybe reCAPTCHA, but in this case I wanted to have a number of fixed images, nothing dynamically generated. I wanted to include the contact form in multiple pages, most of which are `direct_to_template` generic views. However, passing the random image to the `extra_context` of `direct_to_template` didn't work, because the value was only initialized once on startup. Therefore I pass the list of possible choices to `extra_context`, and use the template filter `|random` to select one image. The form's clean method will check if the correct solution was given when `form.is_valid()` is called in the view. If not, the view will display a new captcha. Of course there are other, more elegant solutions like a custom template tag or overriding the generic view, but this works fine for me. Using a fixed number of images will probably not provide good protection for sites that are of much interest to spammers, but for smaller sites it should be sufficient. You can see the CAPTCHA in action at [http://www.lackieren-in-polen.de/](http://www.lackieren-in-polen.de/)
A Django 1.4 wizard mixin for use cases with a wizard step on the frontpage of your site -- with a request path of `'/'`. Just define the name of the step (e.g. `root_step = 'landing_page'`) and it does the setup and redirection automatically.
This field provides a multi select choice field.
Iterate through the supplied iterable and return the `attrname` eattribute of each element in the iterable. Useful with the `join` filter
This snippet is based on [#1051](http://djangosnippets.org/snippets/1051/). It adds filtering by existence of at least one related object. It is an example of how to simply subclass the FilterSpec class, in order to build a custom Filter. The comment in the code contains instructions on how to implement it in a real project.
A simple 2-tuple list of time zones for use in a choice field or select box for Django, or wherever needed.
2955 snippets posted so far.