Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions essenza/product/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@


class ProductForm(forms.ModelForm):
photo = forms.ImageField(
label="Foto (Opcional)", required=False, widget=forms.FileInput
)
remove_photo = forms.BooleanField(required=False, label="Eliminar foto actual")
stock = forms.IntegerField(label="Cantidad en stock", min_value=0, required=False)
is_active = forms.BooleanField(
required=False, label="Producto activo", initial=True
)
description = forms.CharField(
label="Descripción", widget=forms.Textarea(attrs={"rows": 4})
)

class Meta:
model = Product
fields = [
Expand Down
2 changes: 1 addition & 1 deletion essenza/product/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Product(models.Model):
brand = models.CharField(max_length=255)
price = models.DecimalField(max_digits=10, decimal_places=2)
photo = models.ImageField(upload_to="products/", null=True, blank=True)
stock = models.IntegerField()
stock = models.IntegerField(default=0)
is_active = models.BooleanField(default=False)

def __str__(self):
Expand Down
Loading