Wraps many Form subclases in order to get a form wizard to treat them as one.
Many Forms will use one step.
**Example:**
`class LanguageVerifiedHumanForm(MultipleForms):
base_forms = [
('language_form', LanguageForm), ('verified_human_form', VerifiedHumanForm)
]`
`class NewGuideWizard(SessionWizardView):
form_list = [
('guide_form', GuideForm),
('multi_form', LanguageVerifiedHumanForm),
]`
**Designed to hold a list of pages and page ranges for a book/magazine index.**
A custom model field (and accompanying form field) that saves comma-separated pages and page ranges in human-readable string form. Includes some clean-up code, so that you can add a new page or range at the end of an existing entry, and it will put it in numeric order and combine runs into ranges. So this:
4-33, 43, 45, 60-65, 44, 59
becomes the tidy
4-33, 43-45, 59-65
**NOTE:** If you comment out the raising of the `ValidationError` in the form field's validate() method, it will actually clean up any extraneous characters for you (which could be dangerous, but for me is usually what I want), so even this horrible mess:
;4-33, 46a fads i44 ,p45o
gets cleaned to
4-33, 44-46
*This is the first custom field I've ever written for Django, so may be a little rough but seems to work fine.
Validate form field that include email or emails separated by 'token' kwargs, by default ',' a comma. Return a list [] of email(s). Check validity of the email(s) from django EmailField regex (tested with 1.3, but normally will also work with 1.5)
Daniel Roseman's snippet, updated will all fixes mentioned in the comments of the first version + some other things to make it work under Django 1.4.
South, and dumpdata are working.
There's an ugly int(....) at the validate function in order to cast each value as an integer before comparing it to default choices : I needed this, but if you're storing strings values, just remove the int(......) wrapper.
-------------------------------------
Orginal readme
Usually you want to store multiple choices as a manytomany link to another table. Sometimes however it is useful to store them in the model itself. This field implements a model field and an accompanying formfield to store multiple choices as a comma-separated list of values, using the normal CHOICES attribute.
You'll need to set maxlength long enough to cope with the maximum number of choices, plus a comma for each.
The normal get_FOO_display() method returns a comma-delimited string of the expanded values of the selected choices.
The formfield takes an optional max_choices parameter to validate a maximum number of choices.
A Django model manager capable of using different database connections.
Inspired by:
* [Eric Florenzano](http://www.eflorenzano.com/blog/post/easy-multi-database-support-django/)
* [Kenneth Falck](http://kfalck.net/2009/07/01/multiple-databases-and-sharding-with-django)
There's a more detailed version in Portuguese in my blog:
[Manager para diferentes conexões de banco no Django](http://ricobl.wordpress.com/2009/08/06/manager-para-diferentes-conexoes-de-banco-no-django/)
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`
This is a custom field for multiple emails separated by comma. Original code was replaced by code from Django documentation: http://docs.djangoproject.com/en/dev/ref/forms/validation/ (MultiEmailField) so i'm not the author of the code, but just put it here to replace an outdated solution.
Uses code from mksoft comment http://www.djangosnippets.org/snippets/1093/
My modified version of the [MultiQuerySet by mattdw](http://www.djangosnippets.org/snippets/1103/) (see the link for further information).
My purpose for this was to enable me to combine multiple different types of querysets together, which could then be iterated on as one object (i.e. like a tumblelog).
Usually you want to store multiple choices as a manytomany link to another table. Sometimes however it is useful to store them in the model itself. This field implements a model field and an accompanying formfield to store multiple choices as a comma-separated list of values, using the normal CHOICES attribute.
You'll need to set maxlength long enough to cope with the maximum number of choices, plus a comma for each.
The normal get_FOO_display() method returns a comma-delimited string of the expanded values of the selected choices.
The formfield takes an optional max_choices parameter to validate a maximum number of choices.
Observation: depends on jQuery to works!
This widget works like other multiple select widgets, but it shows a drop down field for each choice user does, and aways let a blank choice at the end where the user can choose a new, etc.
Example using it:
class MyForm(forms.ModelForm):
categories = forms.Field(widget=DropDownMultiple)
def __init__(self, *args, **kwargs):
self.base_fields['categories'].widget.choices = Category.objects.values_list('id', 'name')
super(MyForm, self).__init__(*args, **kwargs)
This snippet demonstrates the use of the SpecialOps patch ( [link here](http://hackermojo.com/mt-static/archives/2008/02/django-special-ops.html) )to the django 0.96 admin. Once you have the patch, adding actions like these is simple.
You can use the @admin_action decorator on model and manager methods to expose them inside the admin. For manager methods, the method should accept a list of IDs. For model methods, only self should be required.
Usage:
from yourapp.fields import CheckBoxManyToMany
from django.db import models
class Weekday(models.Model):
name = models.CharField()
def __unicode__(self):
return self.name
class EventWithWeekday(models.Model):
weekdays = CheckBoxManyToMany(Weekday)