firma_backend products and contact section datas

This commit is contained in:
nabijonovdavronbek619@gmail.com
2025-12-02 20:03:33 +05:00
commit b4366eaaba
25 changed files with 307 additions and 0 deletions

0
content/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

21
content/admin.py Normal file
View 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
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class ContentConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'content'

View 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')),
],
),
]

View File

31
content/models.py Normal file
View 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
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
content/views.py Normal file
View File

@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.