When we import device types and the manufacturer was previously created manually, its name may differ in case of characters, for example, SuperMicro, Mikrotik, etc. This results in an IntegrityError in the get_or_create method.
Maybe should use the condition name__iexact=vendor ?
However, the form does not validate if the Manufacturer.name does not match the one specified in the field.initial
model_form.data[field_name] = field.initial
We could solve this problem by rewriting the manufacturer field:
manu = Manufacturer.objects.get(name__iexact=vendor, slug=slugify(vendor))
model_form.data['manufacturer'] = manu.name
Or in some other way, more acceptable, in your opinion.
When we import device types and the manufacturer was previously created manually, its name may differ in case of characters, for example, SuperMicro, Mikrotik, etc. This results in an IntegrityError in the get_or_create method.
Maybe should use the condition
name__iexact=vendor
? However, the form does not validate if the Manufacturer.name does not match the one specified in thefield.initial
We could solve this problem by rewriting the manufacturer field:
Or in some other way, more acceptable, in your opinion.