Skip to content

Instantly share code, notes, and snippets.

@wrought
Created December 3, 2012 09:52
Show Gist options
  • Save wrought/4193954 to your computer and use it in GitHub Desktop.
Save wrought/4193954 to your computer and use it in GitHub Desktop.
django models implementing portion of hackerspaces space api
from django.db import models
class Status(models.Model):
open = models.BooleanField()
status = models.CharField(max_length=None)
lastchange = models.DateTimeField() # needs to be longint
class Events(models.Model): # example is "fire-alarm"
status = models.ForeignKey('Status')
name = models.CharField(max_length=None)
type = models.CharField(max_length=None)
t = models.DateTimeField() # needs to be longint, time since epoch for event
extra = models.TextField()
class Sensors(models.Model):
status = models.OneToOneField('Status')
class Temp(models.Model):
sensors = models.ForeignKey('Sensors')
class TempValue(models.Model):
temp = models.ForeignKey('Temp')
value = models.CharField(max_length=None) # matches ^[-+]?[0-9]+(.[0-9]+)?[FCK]$
class Feeds(models.Model):
status = models.ForeignKey('Status')
name = models.CharField(max_length=None)
type = models.CharField(max_length=None) # mime-type, odd no django field for this
url = models.URLField()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment