From 70f05abdb958ec2da940cc1fdd20175276e67a79 Mon Sep 17 00:00:00 2001 From: Andrey Smakotin Date: Wed, 22 Oct 2025 16:39:49 +0300 Subject: [PATCH] feat: Add SKU field to ProductKit form for kit creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added 'sku' field to ProductKitForm meta fields list - Added SKU label in form labels - Added SKU widget styling in __init__ method with helpful placeholder - Updated productkit_form.html template to display SKU field after name, before description - Updated form field filtering to exclude 'sku' from dynamic loop to prevent duplication πŸ€– Generated with Claude Code Co-Authored-By: Claude --- myproject/products/forms.py | 7 ++++++- .../templates/products/productkit_form.html | 14 +++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/myproject/products/forms.py b/myproject/products/forms.py index 354650d..652ee77 100644 --- a/myproject/products/forms.py +++ b/myproject/products/forms.py @@ -82,11 +82,12 @@ class ProductKitForm(forms.ModelForm): class Meta: model = ProductKit fields = [ - 'name', 'description', 'categories', + 'name', 'sku', 'description', 'categories', 'tags', 'pricing_method', 'fixed_price', 'markup_percent', 'markup_amount', 'is_active' ] labels = { 'name': 'НазваниС', + 'sku': 'Артикул', 'description': 'ОписаниС', 'categories': 'ΠšΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΠΈ', 'tags': 'Π’Π΅Π³ΠΈ', @@ -104,6 +105,10 @@ class ProductKitForm(forms.ModelForm): 'class': 'form-control', 'placeholder': 'Π’Π²Π΅Π΄ΠΈΡ‚Π΅ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΊΠΎΠΌΠΏΠ»Π΅ΠΊΡ‚Π°' }) + self.fields['sku'].widget.attrs.update({ + 'class': 'form-control', + 'placeholder': 'Артикул (Π½Π΅ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎ, Π±ΡƒΠ΄Π΅Ρ‚ сгСнСрирован автоматичСски)' + }) self.fields['description'].widget.attrs.update({ 'class': 'form-control', 'rows': 3 diff --git a/myproject/products/templates/products/productkit_form.html b/myproject/products/templates/products/productkit_form.html index e91bd97..4fb3865 100644 --- a/myproject/products/templates/products/productkit_form.html +++ b/myproject/products/templates/products/productkit_form.html @@ -140,6 +140,18 @@ {% endif %} + +
+ {{ form.sku.label_tag }} + {{ form.sku }} + {% if form.sku.help_text %} + {{ form.sku.help_text }} + {% endif %} + {% if form.sku.errors %} +
{{ form.sku.errors }}
+ {% endif %} +
+
@@ -175,7 +187,7 @@
{% for field in form %} - {% if field.name not in 'name,categories,description,tags' %} + {% if field.name not in 'name,sku,categories,description,tags' %} {% if field.name == 'fixed_price' %}