Skip to content

Instantly share code, notes, and snippets.

@bennett39
Created July 11, 2022 01:00
Show Gist options
  • Save bennett39/9c8f7abc1b535a469760d40ae4ada5bd to your computer and use it in GitHub Desktop.
Save bennett39/9c8f7abc1b535a469760d40ae4ada5bd to your computer and use it in GitHub Desktop.
from django.db import models
class Calculation(models.Model):
"""Track a calculation and its results"""
EQUATION_FIBONACCI = 'FIB'
EQUATIONS = ((EQUATION_FIBONACCI, 'Fibonacci'),)
STATUS_PENDING = 'PENDING'
STATUS_ERROR = 'ERROR'
STATUS_SUCCESS = 'SUCCESS'
STATUSES = (
(STATUS_PENDING, 'Pending'),
(STATUS_ERROR, 'Error'),
(STATUS_SUCCESS, 'Success'),
)
equation = models.CharField(max_length=3, choices=EQUATIONS)
input = models.IntegerField()
output = models.IntegerField(blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True)
status = models.CharField(max_length=8, choices=STATUSES)
message = models.CharField(max_length=110, blank=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment