firma_backend products and contact section datas
This commit is contained in:
0
content/__init__.py
Normal file
0
content/__init__.py
Normal file
BIN
content/__pycache__/__init__.cpython-313.pyc
Normal file
BIN
content/__pycache__/__init__.cpython-313.pyc
Normal file
Binary file not shown.
BIN
content/__pycache__/admin.cpython-313.pyc
Normal file
BIN
content/__pycache__/admin.cpython-313.pyc
Normal file
Binary file not shown.
BIN
content/__pycache__/apps.cpython-313.pyc
Normal file
BIN
content/__pycache__/apps.cpython-313.pyc
Normal file
Binary file not shown.
BIN
content/__pycache__/models.cpython-313.pyc
Normal file
BIN
content/__pycache__/models.cpython-313.pyc
Normal file
Binary file not shown.
21
content/admin.py
Normal file
21
content/admin.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from django.contrib import admin
|
||||
from .models import Product, ProductFeature, ContactMessage
|
||||
|
||||
# ========== INLINE for Product Features ==========
|
||||
class ProductFeatureInline(admin.TabularInline):
|
||||
model = ProductFeature
|
||||
extra = 1
|
||||
|
||||
|
||||
# ========== PRODUCT ADMIN ==========
|
||||
@admin.register(Product)
|
||||
class ProductAdmin(admin.ModelAdmin):
|
||||
list_display = ('name',)
|
||||
inlines = [ProductFeatureInline]
|
||||
|
||||
|
||||
# ========== CONTACT MESSAGE ADMIN ==========
|
||||
@admin.register(ContactMessage)
|
||||
class ContactAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'phone', 'product_name', 'created_at')
|
||||
search_fields = ('name', 'phone', 'product_name')
|
||||
6
content/apps.py
Normal file
6
content/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ContentConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'content'
|
||||
43
content/migrations/0001_initial.py
Normal file
43
content/migrations/0001_initial.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# Generated by Django 5.2.8 on 2025-12-02 14:15
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ContactMessage',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('phone', models.CharField(max_length=20)),
|
||||
('message', models.TextField()),
|
||||
('product_name', models.CharField(blank=True, max_length=255, null=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Product',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('image', models.ImageField(upload_to='products/')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ProductFeature',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('key', models.CharField(max_length=255)),
|
||||
('value', models.CharField(max_length=255)),
|
||||
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='features', to='content.product')),
|
||||
],
|
||||
),
|
||||
]
|
||||
0
content/migrations/__init__.py
Normal file
0
content/migrations/__init__.py
Normal file
BIN
content/migrations/__pycache__/0001_initial.cpython-313.pyc
Normal file
BIN
content/migrations/__pycache__/0001_initial.cpython-313.pyc
Normal file
Binary file not shown.
BIN
content/migrations/__pycache__/__init__.cpython-313.pyc
Normal file
BIN
content/migrations/__pycache__/__init__.cpython-313.pyc
Normal file
Binary file not shown.
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}"
|
||||
3
content/tests.py
Normal file
3
content/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
3
content/views.py
Normal file
3
content/views.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Reference in New Issue
Block a user