Login

Tag "multiple"

Snippet List

Mutiple forms on Form wizard

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), ]`

  • multiple
  • forms
  • wizard
  • multi
  • form-wizard
Read More

MultiRangeField and MultiRangeFormField

**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.

  • multiple
  • stringformat
  • range
  • pages
  • index
Read More

Multiple emails field

Model Field allowing to store multiple emails in one textual field. Emails separated by comma. All emails are validated. Works with Django admin.

  • multiple
  • email
  • validation
  • mail
  • multifield
Read More

Multiple emails form field

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)

  • multiple
  • email
  • validation
  • form
  • field
  • list
Read More

MultiSelectField with comma separated values (Field + FormField)

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.

  • checkbox
  • multiple
  • forms
  • model
  • field
  • comma
Read More

Multiple emails form field

Field which accepts list of e-mail addresses separated by any character, except those which valid e-mail address can contain.

  • multiple
  • email
  • form
  • field
  • list
Read More

Manager for multiple database connections

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/)

  • multiple
  • manager
  • database
  • connection
  • databases
  • connections
Read More
Author: rix
  • 0
  • 6

MultiFormWizard

This is an extended version of the FormWizard which allows display of multiple forms per step and allows usage of ModelForms with initial objects

  • multiple
  • forms
  • form
  • wizzard
  • multi-form-per-step
Read More

MultipleEmailsField

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/

  • multiple
  • forms
  • email
  • field
Read More

(Modified/Improved) MultiQuerySet

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).

  • multiple
  • queryset
  • chain
Read More

Multiple Choice model field

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.

  • multiple
  • model
  • form
Read More

DropDownMultiple widget

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)

  • newforms
  • multiple
  • forms
  • jquery
  • select
  • widget
Read More

Multiple Delete in Admin

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.

  • admin
  • multiple
  • delete
  • hooks
Read More

Select multiple using a manytomany checkbox

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)

  • checkbox
  • multiple
  • oldforms
  • select
Read More

16 snippets posted so far.