 
  
   
  
   
  
   
  
   
  
  loader, объявленный в DownloadBatch.download() и не существующий вне этого метода. 
  
  id_album = models.ForeignKey(Album, related_name="tracks")album.tracks.all().<ul>
{% for album in albums %}
  <li>{{ album.artist }} - {{album.disc}}
    <ol>
    {% for track in album.track_set.all %}
      <li>{{ track.title }}</li>
    {% endfor %}
    </ol>
  </li>
{% endfor %}albums = Album.objects.select_related().order_by('id_album').all()[ 0:10]class Album(models.Model):
    artist = models.CharField(max_length=100, null=True)
    disc = models.CharField(max_length=100, null=True)
 
class Track(models.Model):
    album = models.ForeignKey(Album)
    title = models.CharField(max_length=100)  pidfile = "/tmp/server.pid"
  def check_pid(pid):
    """ Check For the existence of a unix pid. """
    try:
      os.kill(pid, 0)
    except OSError:
      return False
    else:
      return True
  if os.path.isfile(pidfile):
    pid = long(open(pidfile, 'r').read())
    if check_pid(pid):
      print "%s already exists, exiting" % pidfile
      sys.exit()
  pid = str(os.getpid())
  file(pidfile, 'w').write(pid)
  # actual code
  # finish
  os.unlink(pidfile)
* This source code was highlighted with Source Code Highlighter. 
  
  insert into words (id, type, word) select suppliers_store.id, 'name', 'панель' и делается индекс (type, word, id). Соотв. поиск производится по этой табличке без испрользования %.       
  
   
  
   
  
  
class MetaComp(type):
  def __init__(cls,name,bases,kwargs):
    super(MetaComp, cls).__init__(name,bases,kwargs)
    cls.connects = [] # для каждого класса и наследника будеит свой
class Comp(object):
  __metaclass__ = MetaComp
  @classmethod
  def connect(cls,obj):
    cls.connects.append(obj)
class Comp1(Comp):
  pass
    
class Comp2(Comp):
  pass
# каждый вызов добавляет к своему connects:
Comp.connect('foo')
Comp1.connect('foo1')
Comp2.connect('foo2')