firma_backend products and contact section datas
This commit is contained in:
31
content/models.py
Normal file
31
content/models.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from django.db import models
|
||||
|
||||
# ======== PRODUCT MODEL ========
|
||||
class Product(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
image = models.ImageField(upload_to='products/')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
# ======== PRODUCT FEATURES (KEY-VALUE) ========
|
||||
class ProductFeature(models.Model):
|
||||
product = models.ForeignKey(Product, related_name='features', on_delete=models.CASCADE)
|
||||
key = models.CharField(max_length=255)
|
||||
value = models.CharField(max_length=255)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.product.name} - {self.key}"
|
||||
|
||||
|
||||
# ======== CONTACT FORM DATA ========
|
||||
class ContactMessage(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
phone = models.CharField(max_length=20)
|
||||
message = models.TextField()
|
||||
product_name = models.CharField(max_length=255, blank=True, null=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"Message from {self.name}"
|
||||
Reference in New Issue
Block a user