djangosnippets.org: Latest snippets tagged with 'multiple'https://djangosnippets.org/tags/multiple/2015-09-11T03:57:46.837022-05:00Mutiple forms on Form wizard
2015-09-11T03:57:46.837022-05:00LaraChicharohttps://djangosnippets.org/snippets/10528/<p>Wraps many Form subclases in order to get a form wizard to treat them as one.</p>
<p>Many Forms will use one step.</p>
<p><strong>Example:</strong></p>
<p><code>class LanguageVerifiedHumanForm(MultipleForms):
base_forms = [
('language_form', LanguageForm), ('verified_human_form', VerifiedHumanForm)
]</code></p>
<p><code>class NewGuideWizard(SessionWizardView):
form_list = [
('guide_form', GuideForm),
('multi_form', LanguageVerifiedHumanForm),
]</code></p>
Freely redistributableMultiRangeField and MultiRangeFormField
2014-06-01T12:14:28.673304-05:00bobtikihttps://djangosnippets.org/snippets/3070/<p><strong>Designed to hold a list of pages and page ranges for a book/magazine index.</strong></p>
<p>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 …</p>
Freely redistributableMultiple emails field
2014-05-06T09:14:36.037016-05:00cuchachttps://djangosnippets.org/snippets/3047/<p>Model Field allowing to store multiple emails in one textual field. Emails separated by comma. All emails are validated. Works with Django admin.</p>
Freely redistributableMultiple emails form field
2013-12-17T14:48:42.881052-06:00matrixhttps://djangosnippets.org/snippets/3012/<p>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)</p>
Freely redistributableMultiSelectField with comma separated values (Field + FormField)
2012-05-17T17:23:26.180755-05:00quinodehttps://djangosnippets.org/snippets/2753/<p>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.<br />
South, and dumpdata are working.</p>
<p>There's an ugly int(....) at the validate function in order to cast each value as an integer before comparing …</p>
Freely redistributableMultiple emails form field
2010-03-15T12:47:40.771983-05:00virhilohttps://djangosnippets.org/snippets/1958/<p>Field which accepts list of e-mail addresses separated by any character, except those which valid e-mail address can contain.</p>
Freely redistributableManager for multiple database connections
2009-08-06T19:21:54.796953-05:00rixhttps://djangosnippets.org/snippets/1674/<p>A Django model manager capable of using different database connections.</p>
<p>Inspired by:</p>
<ul>
<li><a href="http://www.eflorenzano.com/blog/post/easy-multi-database-support-django/">Eric Florenzano</a></li>
<li><a href="http://kfalck.net/2009/07/01/multiple-databases-and-sharding-with-django">Kenneth Falck</a></li>
</ul>
<p>There's a more detailed version in Portuguese in my blog:
<a href="http://ricobl.wordpress.com/2009/08/06/manager-para-diferentes-conexoes-de-banco-no-django/">Manager para diferentes conexões de banco no Django</a></p>
Freely redistributableMultiFormWizard
2009-05-20T11:37:07.509104-05:00flashingpumpkinhttps://djangosnippets.org/snippets/1514/<p>This is an extended version of the FormWizard which allows display of multiple forms per step and allows usage of ModelForms with initial objects</p>
Freely redistributableServe multiple hostnames with different URLCONF's from one Django instance
2009-05-17T05:42:32.635660-05:00rmthttps://djangosnippets.org/snippets/1509/<p>This works with <code>Django 1.0.0</code> and later. It sets the <code>request.urlconf</code> variable to an alternate urlconf, if there's a match to the hostname in <code>settings.MULTIHOST_URLCONF_MAP</code></p>
Freely redistributableMultipleEmailsField
2009-04-24T10:08:08.298836-05:00spanasikhttps://djangosnippets.org/snippets/1464/<p>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. </p>
<p>Uses code from mksoft comment http://www.djangosnippets.org/snippets/1093/</p>
Freely redistributable(Modified/Improved) MultiQuerySet
2008-12-17T10:17:46.502187-06:00joonashttps://djangosnippets.org/snippets/1253/<p>My modified version of the <a href="http://www.djangosnippets.org/snippets/1103/">MultiQuerySet by mattdw</a> (see the link for further information).</p>
<p>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).</p>
Freely redistributableMultiple Choice model field
2008-11-18T00:56:09.079212-06:00danielrosemanhttps://djangosnippets.org/snippets/1200/<p>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 …</p>
Freely redistributableDropDownMultiple widget
2008-05-09T05:38:36.713915-05:00marinhohttps://djangosnippets.org/snippets/747/<p>Observation: depends on jQuery to works!</p>
<p>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.</p>
<p>Example using it:</p>
<pre><code>class MyForm(forms.ModelForm):
categories = …</code></pre>
Freely redistributableMultiple Delete in Admin
2008-03-02T16:36:33.818876-06:00gfranxmanhttps://djangosnippets.org/snippets/626/<p>This snippet demonstrates the use of the SpecialOps patch ( <a href="http://hackermojo.com/mt-static/archives/2008/02/django-special-ops.html">link here</a> )to the django 0.96 admin. Once you have the patch, adding actions like these is simple. </p>
<p>You can use the @admin_action decorator on model and manager methods to expose them inside the admin. For manager methods, the method …</p>
Freely redistributableSelect multiple using a manytomany checkbox
2007-11-22T08:17:50.101206-06:00fivethreeohttps://djangosnippets.org/snippets/480/<p>Usage:</p>
<pre><code>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)
</code></pre>
Freely redistributable