2017-08-26 11:40:35 -04:00
|
|
|
from django.db import models
|
|
|
|
from django.contrib.auth.models import User
|
|
|
|
|
|
|
|
|
|
|
|
class Thread(models.Model):
|
|
|
|
topic = models.CharField(max_length=255)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.topic
|
|
|
|
|
|
|
|
|
|
|
|
class Post(models.Model):
|
|
|
|
topic = models.ForeignKey(Thread)
|
|
|
|
title = models.CharField(max_length=255)
|
2018-01-02 17:27:59 -05:00
|
|
|
question = models.TextField()
|
2017-08-26 11:40:35 -04:00
|
|
|
creator = models.ForeignKey(User)
|
|
|
|
created = models.DateTimeField(auto_now_add=True)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
|
|
|
|
class Comment(models.Model):
|
|
|
|
post = models.ForeignKey(Post)
|
2018-01-02 17:27:59 -05:00
|
|
|
reply = models.TextField()
|
2017-08-26 11:40:35 -04:00
|
|
|
creator = models.ForeignKey(User)
|
|
|
|
created = models.DateTimeField(auto_now_add=True)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.reply
|