Priyatham-sai-chand/auctions/models.py

25 lines
1.0 KiB
Python
Raw Normal View History

2020-10-15 10:18:39 -07:00
from django.contrib.auth.models import AbstractUser
from django.db import models
class User(AbstractUser):
2020-10-16 09:38:28 -07:00
watchlist = models.ManyToManyField('AuctionListing',blank = True,related_name="watchlist")
2020-10-15 10:18:39 -07:00
class AuctionListing(models.Model):
title = models.CharField(max_length = 64,primary_key = True)
user = models.ForeignKey(User,on_delete = models.CASCADE,default = " ")
price = models.DecimalField(max_digits = 10,decimal_places = 2)
desc = models.CharField(max_length = 1000)
picture = models.URLField(null=True)
2020-10-16 09:38:28 -07:00
category = models.CharField(max_length = 64,default = " ")
2020-10-15 10:18:39 -07:00
2020-10-16 09:38:28 -07:00
2020-10-15 10:18:39 -07:00
def __str__(self):
return f"{self.title}: {self.price},{self.desc},{self.picture}"
class Comments(models.Model):
title = models.ForeignKey(AuctionListing,on_delete = models.CASCADE,related_name="auction_title")
comment = models.CharField(max_length = 1000)
2020-10-16 09:38:28 -07:00
class bidding(models.Model):
bidder = models.ForeignKey(User,on_delete = models.CASCADE,default = " ")
bid = models.DecimalField(max_digits = 10,decimal_places = 2)