update
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from django.contrib import admin
|
||||
from product.models import *
|
||||
|
||||
# Register your models here.
|
||||
admin.site.register(productPageSEO)
|
||||
13
product/forms.py
Normal file
13
product/forms.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django import forms
|
||||
from product.models import *
|
||||
|
||||
# Service Page SEO Form
|
||||
class productPageSEOForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = productPageSEO
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
for field in self.fields.values():
|
||||
field.widget.attrs['class'] = 'form-control'
|
||||
22
product/migrations/0001_initial.py
Normal file
22
product/migrations/0001_initial.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 4.2.4 on 2023-09-16 15:21
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='productPageSEO',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('meta_title', models.CharField(blank=True, max_length=500, null=True)),
|
||||
('meta_description', models.CharField(blank=True, max_length=1000, null=True)),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
# Generated by Django 5.0.3 on 2024-11-22 08:36
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='servicePageSEO',
|
||||
new_name='productPageSEO',
|
||||
),
|
||||
]
|
||||
@@ -1,3 +1,6 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class productPageSEO(models.Model):
|
||||
meta_title = models.CharField(max_length=500, blank=True, null=True)
|
||||
meta_description = models.CharField(max_length=1000, blank=True, null=True)
|
||||
7
product/urls.py
Normal file
7
product/urls.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from django.urls import path
|
||||
from product.views import *
|
||||
|
||||
urlpatterns = [
|
||||
path('products/', productFrontPage, name='productFrontPage'),
|
||||
path('product/details/<str:slug>/', productDetail, name='productDetail'),
|
||||
]
|
||||
@@ -1,3 +1,31 @@
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from product.models import productPageSEO
|
||||
from home.models import *
|
||||
|
||||
def productFrontPage(request):
|
||||
seo = productPageSEO.objects.first()
|
||||
products = productSection.objects.all()
|
||||
sliders = sliderSection.objects.all()
|
||||
|
||||
context ={
|
||||
'sliders' : sliders,
|
||||
'seo' : seo,
|
||||
'products' : products,
|
||||
|
||||
}
|
||||
return render(request, 'front/main/product.html', context)
|
||||
|
||||
def productDetail(request, slug):
|
||||
product = get_object_or_404(productSection, slug=slug)
|
||||
products = productSection.objects.all()
|
||||
|
||||
context = {
|
||||
'product' : product,
|
||||
'products' : products,
|
||||
}
|
||||
return render(request, 'front/main/partial/product-details.html', context)
|
||||
|
||||
|
||||
def error_404(request, exception):
|
||||
return render(request, 'error/404.html', status=404)
|
||||
|
||||
# Create your views here.
|
||||
|
||||
Reference in New Issue
Block a user