build:project build
This commit is contained in:
20
website/smalltalkapp/models.py
Normal file
20
website/smalltalkapp/models.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from django.db import models
|
||||
from .unity.username_random import RandomName
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class Smalltalk(models.Model):
|
||||
username = models.CharField(max_length=100)
|
||||
content = models.TextField()
|
||||
score = models.IntegerField(choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)])
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.username:
|
||||
self.username = RandomName.generate_name()
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user