Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 17th, 2012  |  syntax: None  |  size: 0.71 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. from django.db import models
  2. from django.db.models import Count
  3. from datetime import date, timedelta
  4.  
  5.  
  6. class CinemaInfoManager(models.Manager):
  7.     def get_query_set(self):
  8.         qs = super(CinemaInfoManager, self).get_query_set()
  9.         return qs.filter({'inicio__lte': date.today(), 'fim__gte': date.today()})
  10.  
  11.  
  12. class CinemaInfo(models.Model):
  13.     codigo = models.IntegerField(primary_key=True, db_column='CODIGO')
  14.     cinema = models.ForeignKey('Cinema', db_column='COD_CINEMA')
  15.     obs = models.TextField(db_column='OBS')
  16.     inicio = models.DateField(db_column='DATA_I')
  17.     fim = models.DateField(db_column='DATA_F')
  18.     objects = CinemaInfoManager()
  19.  
  20.     class Meta:
  21.         db_table = u'OBS_CINE'
  22.         managed = False