Skip to content

Instantly share code, notes, and snippets.

@lawlesst
Created July 23, 2011 12:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save lawlesst/1101367 to your computer and use it in GitHub Desktop.
Sample Django models for library reports.
class Accession(models.Model):
"""Sample for recording library statistics.
Use indexes for faster query time.."""
number = models.CharField(max_length=15, primary_key=True)
created = models.DateField(db_index=True)
acquisition_method = models.CharField(max_length=50, db_index=True)
format = models.CharField(max_length=50, db_index=True)
location = models.CharField(max_length=50, db_index=True)
volumes = models.IntegerField()
titles = models.IntegerField()
serial_added_volume = models.BooleanField(default=False)
def __unicode__(self):
return u'%s %s %s %s' % (self.created, self.acquisition_method, self.location, self.format)
class CatEdit(models.Model):
"""Sample cataloging statistics model."""
id = models.CharField(max_length=50, primary_key=True)
edit_date = models.DateField(db_index=True)
bib = models.CharField(max_length=15)
mat_type = models.CharField(max_length=15, db_index=True)
editor = models.CharField(max_length=50, db_index=True)
type = models.CharField(max_length=50, db_index=True)
source = models.CharField(max_length=15, blank=True, null=True, db_index=True)
def __unicode__(self):
return u'%s %s' % (self.edit_date, self.editor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment