model python

Solutions on MaxInterview for model python by the best coders in the world

showing results for - "model python"
Storm
30 Mar 2019
1from django.db import models
2from django.contrib.auth.models import User
3
4class Board(models.Model):
5	name = models.CharField(max_length=30, unique=True)
6	description = models.CharField(max_length=100)
7
8class Topic(models.Model):
9	subject = models.CharField(max_length=255)
10	last_updated = models.DateTimeField(auto_now_add=True)
11	board = models.ForeignKey(Board, related_name='topics')
12	starter = models.ForeignKey(User, related_name='topics')
13
14class Post(models.Model):
15	message = models.TextField(max_length=4000)
16	topic = models.ForeignKey(Topic, related_name='posts')
17	created_at = models.DateTimeField(auto_now_add=True)
18	updated_at = models.DateTimeField(null=True)
19	created_by = models.ForeignKey(User, related_name='posts')
20	updated_by = models.ForeignKey(User, null=True, related_name='+')
21