Skip to content

Instantly share code, notes, and snippets.

@codeboy101
Created October 29, 2016 17:49
Show Gist options
  • Select an option

  • Save codeboy101/38e61471a8c764f9461048daa58dbc60 to your computer and use it in GitHub Desktop.

Select an option

Save codeboy101/38e61471a8c764f9461048daa58dbc60 to your computer and use it in GitHub Desktop.
from django.db import models
from django.utils import timezone
from datetime import date
from django.contrib.auth.models import User
class Story(models.Model):
title = models.CharField(max_length=75)
body = models.TextField()
author = models.CharField(default="",max_length=75)
pub_date = models.DateTimeField(default=timezone.now)
total_votes = models.IntegerField(default=0)
def __str__(self):
return self.title
class Vote(models.Model):
story = models.ForeignKey(Story,null=True)
voter = models.ForeignKey(User,null=True)
has_voted = models.BooleanField(default=False)
vote_cast = models.IntegerField(default=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment