22 lines
768 B
Python
22 lines
768 B
Python
|
from django.contrib.auth.models import AbstractUser
|
||
|
from django.db import models
|
||
|
|
||
|
class User(AbstractUser):
|
||
|
watchlist = models.ManyToManyField('AuctionListing',blank = True,related_name="watchlist")
|
||
|
|
||
|
class AuctionListing(models.Model):
|
||
|
title = models.CharField(max_length = 64,primary_key = True)
|
||
|
user = models.ForeignKey(User,on_delete = models.CASCADE)
|
||
|
price = models.DecimalField(max_digits = 10,decimal_places = 2)
|
||
|
desc = models.CharField(max_length = 1000)
|
||
|
picture = models.URLField(null=True)
|
||
|
category = models.CharField(max_length = 64)
|
||
|
date_added = models.DateTimeField(auto_now_add=True)
|
||
|
|
||
|
def __str__(self):
|
||
|
return f"{self.title}: {self.price},{self.desc},{self.picture},{self.category},{self.date_added}"
|
||
|
|
||
|
|
||
|
|
||
|
|