djangosnippets.org: Latest snippets tagged with 'chain'http://djangosnippets.org/tags/chain/2010-02-20T14:11:02.419194-06:00Multiple querysets
2010-02-20T14:11:02.419194-06:00t_rybikhttp://djangosnippets.org/snippets/1933/<p>This is an upgrade of snippet <a href="http://www.djangosnippets.org/snippets/1103/">1103</a>.</p>
<p>Exemplary usage:</p>
<pre><code>class Blog(models.Model):
name = models.CharField(max_length=100)
def __unicode__(self):
return self.name
class Post(models.Model):
title = models.CharField(max_length=50)
blog = models.ForeignKey(Blog)
def __unicode__(self):
return self.title
class Meta:
abstract=True
class Article(Post):
text = models.TextField()
class Link(Post):
url = models.URLField()
blog = Blog(name="Exemplary blog")
blog.save()
Article(title="#1", …</code></pre>
Freely redistributable(Modified/Improved) MultiQuerySet
2008-12-17T10:17:46.502187-06:00joonashttp://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 redistributableChain multiple querysets into one
2008-10-01T17:10:18.657351-05:00mattdwhttp://djangosnippets.org/snippets/1103/<p>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:</p>
<pre><code>>>> qs1 = Event.objects.filter(## title matches ##)
>>> qs2 = Event.objects.filter(## matches in other fields …</code></pre>
Freely redistributableJavascript Chain Select Widget
2008-06-02T10:19:39.533473-05:00ogohttp://djangosnippets.org/snippets/782/<p>This widget will render a chained select menu powered by JavaScript to make it easier to identify foreign keys. This widget includes danjak's form decorator (http://www.djangosnippets.org/snippets/59/), and Xin Yang's chained select javascript functions (http://www.yxscripts.com/).</p>
<p>I developed this to be used with an IT inventory system. See screenshot here: http://bayimg.com/cAjAGAabN
The …</p>
Freely redistributable