Answer the question
In order to leave comments, you need to log in
Django throws an error (something related to the database) what to do?
class Products(models.Model):
name = models.CharField("Имя продукта", max_length = 150)
img = models.ImageField("Изображение", upload_to = "product/")
description = models.TextField("Описание")
cost = models.IntegerField("цена", default = 0)
in_stock = models.BooleanField("наличие", default=False)
hot = models.BooleanField("Хит", default = False)
sale = models.BooleanField("Скидка", default=False)
kg = models.BooleanField("В кг", default=True)
litr = models.BooleanField("В литрах", default=False)
draft = models.BooleanField("черновик", default=False)
url = models.SlugField(max_length=160, unique = True)
def __str__(self):
return {self.name}
class Meta:
verbose_name = 'Продукт'
verbose_name_plural = "Продукты"
class Products_tip(models.Model):
name = models.CharField("Имя типа продукта", max_length = 150)
id_tip = models.CharField("ID типа", max_length=160, unique=True)
foregin = models.ForeignKey(Products, verbose_name='Тип товара', null=True, on_delete=models.SET_NULL)
def __str__(self):
return f'{self.name} - {self.id_tip}'
class Meta:
verbose_name='Тип'
verbose_name_plural = "Типы"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question