File size: 804 Bytes
46d747a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from django.db import models
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
import uuid
# ChatHistory Model
class Room(models.Model):
    RoomID = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    UserName = models.CharField(max_length=50)
    Name = models.CharField(max_length=50,null=True)
    def __str__(self):
        return f'Chat {self.RoomID} by {self.UserName}'

# ChatDetails Model
class ChatDetails(models.Model):
    RoomID = models.ForeignKey(Room, on_delete=models.CASCADE)
    order = models.AutoField(primary_key=True)
    UserPrompt = models.TextField()
    BotResponse = models.TextField(null=True)

    class Meta:
        ordering = ['order']    

    def __str__(self):
        return f'Message {self.order} in Chat {self.RoomID}'