A rewrite of the django.contrib.formtools.FormWizard class to be session-based instead of saving state in hidden form variables.
It started out as a simple port of the standard FormWizard class, and much of the original behavior was unchanged because I wanted to limit the scope of the "rewrite". Along the way I think I made it a bit more OO, and a bit more flexible, but there are still warts.
I threw this code up here before I was completely happy with it just to take part in the discussion around [this ticket][http://code.djangoproject.com/ticket/9200 "Django Ticket #9200]. There's certainly a few things that the patch on that ticket does that I'd like to incorporate into my Wizard, whenever time allows.
A simple filter which divides an iterable (list, tupe, string, etc) in chunks, which can then be iterated over separately. A sample of the filter usage is given: a gallery template in which I needed to display images in a table, three images per row, one row for images followed by one row for their descriptions.
This dead-simple piece of middleware adds a terrific security feature to django authentication. Currently, users who's accounts are de-activated still may have a cookie and a login session. This middleware destroys that session on their next request.
Simply add this class into a middleware.py and add it to your settings.
These field and widget are util for to those fields where you can put a star and end values.
It supports most of field types and widgets (tested with IntegerField, CharField and DateField / TextInput and a customized DateInput).
**Example of use:**
class FormSearch(forms.Form):
q = forms.CharField(max_length=50, label=_('Search for'))
price_range = RangeField(forms.IntegerField, required=False)
**Example of use (with forced widget):**
class FormSearch(forms.Form):
q = forms.CharField(max_length=50, label=_('Search for'))
price_range = RangeField(forms.IntegerField, widget=MyWidget)
This class acts as a wrapper around multiple querysets. Use it if you want to chain multiple QSs together without combining them with | or &. eg., to put title matches ahead of body matches:
>>> qs1 = Event.objects.filter(## title matches ##)
>>> qs2 = Event.objects.filter(## matches in other fields ##)
>>> qs = MultiQuerySet(qs1, qs2)
>>> len(qs)
>>> paginator = Paginator(qs)
>>> first_ten = qs[:10]
It effectively acts as an immutable, sliceable QuerySet (with only a very limited subset of the QuerySet api)
Add this code to you your context_processors.py in your project and then install it in your settings.py TEMPLATE_CONTEXT_PROCESSORS. In your template you can print out a segment of a url by using {{ segment_1 }}. For example if you're on the page "/mysite/section1/section2/" and you used {{ segment_2 }} it would print section1.
This idea was taken from Expression Engines URL Segments, http://expressionengine.com/docs/templates/globals/url_segments.html.
This comes in handy if you only want to do something in your template if the page your on has a particular segment.
FYI, I haven't used this in a production setting yet so it could be buggy still.
**So you can upload rectangular pictures but still have square thumbnails.**
"Scale to **fill**" instead of the out of the box "scale to **fit**" you get with `Image.thumbnail`
Django SITE_ID is a global setting, so the site framework requires you to run multiple instances of Django; at least one for each site. But i want have one instance for multiple sites. This snippet solve this task by change SITE_ID on fly.
/sorry my bad english/
Adds an additional template dir to settings.TEMPLATE_DIRS if the request's HTTP_USER_AGENT string has the word iPhone in it. Allows you to easily create iPhone templates.
This is a general JQuery Autocomplete Form Field for selecting any model instance in your forms.
1 Download jquery.1.2.6 and the jquery autocomplete plugin http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/, place theme somewhere in your media directory (in this case {{ MEDIA__URL}}/js/
2 copy fields.py to anywhere in your python-path (in this case utils.fields)
3 create a view for the ajax request that receives a query and returns a key|value list, and register it in your urls.py
4 Just Use the fields in any form like in forms.py