2022-10-08 13:52:49 +03:00
|
|
|
from django.core.validators import MinValueValidator
|
2022-10-08 00:48:53 +03:00
|
|
|
from django.db import models
|
|
|
|
|
2022-10-08 11:21:53 +03:00
|
|
|
from users.models import User
|
|
|
|
|
|
|
|
|
|
|
|
class Product(models.Model):
|
|
|
|
name = models.CharField(max_length=200)
|
2022-10-08 14:39:52 +03:00
|
|
|
slug = models.SlugField(max_length=20, null=True)
|
2022-10-08 11:21:53 +03:00
|
|
|
description = models.TextField(blank=True)
|
|
|
|
|
|
|
|
image = models.ImageField(upload_to="uploads/")
|
|
|
|
image_cropped = models.ImageField(upload_to="cropped/", blank=True)
|
|
|
|
nft = models.CharField(max_length=500, blank=True)
|
|
|
|
|
2022-10-08 13:52:49 +03:00
|
|
|
price = models.IntegerField(validators=[MinValueValidator(0)])
|
2022-10-08 11:21:53 +03:00
|
|
|
creator = models.ForeignKey(User, related_name="products", on_delete=models.CASCADE)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|