remove NULL from all text fields in database

This commit is contained in:
Mario Hüttel 2022-01-01 14:06:46 +01:00
parent c4a26f8a98
commit 563a769064
3 changed files with 64 additions and 10 deletions

View File

@ -0,0 +1,49 @@
# Generated by Django 3.2.5 on 2022-01-01 13:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('parts', '0008_auto_20220101_1250'),
]
operations = [
migrations.AlterField(
model_name='component',
name='datasheet_link',
field=models.CharField(blank=True, default='', max_length=300),
preserve_default=False,
),
migrations.AlterField(
model_name='component',
name='description',
field=models.TextField(blank=True, default=''),
preserve_default=False,
),
migrations.AlterField(
model_name='componentparameter',
name='text_value',
field=models.TextField(blank=True, default=''),
preserve_default=False,
),
migrations.AlterField(
model_name='distributor',
name='component_link_pattern',
field=models.CharField(blank=True, default='', max_length=255),
preserve_default=False,
),
migrations.AlterField(
model_name='distributor',
name='website',
field=models.CharField(blank=True, default='', max_length=200),
preserve_default=False,
),
migrations.AlterField(
model_name='manufacturer',
name='website',
field=models.CharField(blank=True, default='', max_length=200),
preserve_default=False,
),
]

View File

@ -116,9 +116,9 @@ class Distributor(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True)
name = models.CharField(max_length=100, unique=True)
website = models.CharField(max_length=200, null=True, blank=True)
website = models.CharField(max_length=200, null=False, blank=True)
image = models.ImageField(upload_to=RandomFileName.RandomFileName('distributor-logos'), null=True, blank=True)
component_link_pattern = models.CharField(max_length=255, blank=True, null=True)
component_link_pattern = models.CharField(max_length=255, blank=True, null=False)
def __str__(self):
return self.name
@ -144,7 +144,7 @@ class Manufacturer(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True)
name = models.CharField(max_length=100, unique=True)
website = models.CharField(max_length=200, null=True, blank=True)
website = models.CharField(max_length=200, null=False, blank=True)
image = models.ImageField(upload_to=RandomFileName.RandomFileName('manufacturer-images'), blank=True, null=True)
def __str__(self):
@ -161,8 +161,8 @@ class Component(models.Model):
manufacturer = models.ForeignKey(Manufacturer, on_delete=models.PROTECT, blank=True, null=True)
component_type = models.ForeignKey(ComponentType, on_delete=models.SET_NULL, blank=True, null=True)
pref_distri = models.ForeignKey(Distributor, on_delete=models.PROTECT, blank=True, null=True)
description = models.TextField(null=True, blank=True)
datasheet_link = models.CharField(max_length=300, null=True, blank=True)
description = models.TextField(null=False, blank=True)
datasheet_link = models.CharField(max_length=300, null=False, blank=True)
package = models.ForeignKey(Package, on_delete=models.PROTECT, blank=True, null=True)
image = models.ImageField(upload_to=RandomFileName.RandomFileName('component-images'), blank=True, null=True)
@ -208,7 +208,7 @@ class ComponentParameter(models.Model):
component = models.ForeignKey(Component, on_delete=models.CASCADE) # A target component is required!
parameter_type = models.ForeignKey(ComponentParameterType, on_delete=models.CASCADE)
value = models.FloatField(default=0)
text_value = models.TextField(null=True, blank=True)
text_value = models.TextField(null=False, blank=True)
def __str__(self):
if self.parameter_type.parameter_type == 'F':

View File

@ -2,7 +2,7 @@
<input autocomplete="off" id="{{widget.attrs.id}}" data-ac-url="{{custom.search_url}}" data-bs-toggle="dropdown" type="text" placeholder="Search..." class="{{widget.attrs.class}}">
<ul id="{{widget.attrs.id}}-ac-ul" class="dropdown-menu">
</ul>
<div class="d-flex align-items-center" id="{{widget.attrs.id}}-dflex-container">
<div class="d-flex align-items-center mt-3 mb-3" id="{{widget.attrs.id}}-dflex-container">
{% if custom.current_instance %}
{% if custom.image_field_name %}
<div class="flex-shrink-0">
@ -15,13 +15,18 @@
</div>
{% endif %}
{% endif %}
<div class="flex-grow-1 ms-3">
<div class="ms-3">
{% if custom.current_instance %}
{{custom.current_instance}}
{{custom.current_instance}}
{% else %}
<span class="text-secondary">None selected</span>
{% endif %}
</div>
{% if custom.current_instance %}
<div class="ms-4">
<span class="btn btn-close" data-ac-delete="{{widget.attrs.id}}"></span>
</div>
{% endif %}
</div>
<input type="hidden" {% if widget.value != None %}value="{{widget.value}}"{%endif%} name={{widget.name}}>
<input type="hidden" {% if widget.value != None %}value="{{widget.value}}"{%endif%} name={{widget.name}} id="{{widget.attrs.id}}-uuid-field">
</div>