simple-plant-archive-django/plant_catalog/catalog/models.py

13 lines
487 B
Python
Raw Permalink Normal View History

2024-10-05 17:30:35 +02:00
from django.db import models
class Plant(models.Model):
name = models.CharField(max_length=100)
2025-03-02 10:43:19 +01:00
description = models.TextField(null=True, blank=True)
buy_price = models.FloatField(null=True, blank=True)
sell_price = models.FloatField(null=True, blank=True)
stock = models.IntegerField(default=0)
2024-10-05 17:30:35 +02:00
2025-03-02 10:43:19 +01:00
class PlantImage(models.Model):
plant = models.ForeignKey(Plant, related_name='images', on_delete=models.CASCADE)
image = models.ImageField(upload_to='plants/')