diff --git a/ups_management/ups_manager/forms.py b/ups_management/ups_manager/forms.py index e1b9961..972c203 100644 --- a/ups_management/ups_manager/forms.py +++ b/ups_management/ups_manager/forms.py @@ -6,10 +6,11 @@ from .models import UPSHost, Battery class UPSHostForm(forms.ModelForm): class Meta: model = UPSHost - fields = ['brand', 'model', 'ip_address', 'quantity', 'location', 'last_maintenance_date', 'contact'] + fields = ['brand', 'model', 'serial_number', 'ip_address', 'quantity', 'location', 'last_maintenance_date', 'contact'] labels = { 'brand': '品牌', 'model': '型号', + 'serial_number': '序列号', 'ip_address': 'IP地址', 'quantity': '数量', 'location': '存放位置', @@ -19,6 +20,7 @@ class UPSHostForm(forms.ModelForm): widgets = { 'brand': forms.TextInput(attrs={'class': 'form-control'}), 'model': forms.TextInput(attrs={'class': 'form-control'}), + 'serial_number': forms.TextInput(attrs={'class': 'form-control'}), 'ip_address': forms.TextInput(attrs={'class': 'form-control'}), 'quantity': forms.NumberInput(attrs={'class': 'form-control', 'min': '1'}), 'location': forms.TextInput(attrs={'class': 'form-control'}), diff --git a/ups_management/ups_manager/migrations/0006_upshost_serial_number.py b/ups_management/ups_manager/migrations/0006_upshost_serial_number.py new file mode 100644 index 0000000..234acec --- /dev/null +++ b/ups_management/ups_manager/migrations/0006_upshost_serial_number.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.6 on 2026-05-18 05:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ups_manager', '0005_alter_upshost_ip_address'), + ] + + operations = [ + migrations.AddField( + model_name='upshost', + name='serial_number', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='序列号'), + ), + ] diff --git a/ups_management/ups_manager/models.py b/ups_management/ups_manager/models.py index c5abdc2..52e9585 100644 --- a/ups_management/ups_manager/models.py +++ b/ups_management/ups_manager/models.py @@ -36,6 +36,7 @@ class Supplier(models.Model): class UPSHost(models.Model): brand = models.CharField(max_length=100, verbose_name='品牌') model = models.CharField(max_length=100, verbose_name='型号') + serial_number = models.CharField(max_length=100, blank=True, null=True, verbose_name='序列号') ip_address = models.CharField(max_length=50, blank=True, null=True, verbose_name='IP地址') quantity = models.IntegerField(default=1, verbose_name='数量') location = models.CharField(max_length=200, verbose_name='存放位置') diff --git a/ups_management/ups_manager/templates/ups_manager/ups_form.html b/ups_management/ups_manager/templates/ups_manager/ups_form.html index 0bb4b01..9b54e9a 100644 --- a/ups_management/ups_manager/templates/ups_manager/ups_form.html +++ b/ups_management/ups_manager/templates/ups_manager/ups_form.html @@ -40,6 +40,20 @@ +
+
+ + {{ form.serial_number }} + {% if form.serial_number.errors %} + {% for error in form.serial_number.errors %} +
{{ error }}
+ {% endfor %} + {% endif %} +
+
+