Sunday, January 3, 2021

how to validate empty field value in django 'import_export' at db level

Hello everyone I have created one webpage where I am using Django 'import_export' Resource for .xlsfile upload. I am having below fields name in the .xls file as shown below image.

shift.png

Now here id is my primary key and upload functionality is working fine. Now I want that when the user is uploading details AConnectID should be checked/validated and if it is blank then the process should stop.

I have tried using null=False and validator but it is working at the form level.

AConnectID = models.CharField(max_length=100, null=False,validators= [validators.MinLengthValidator(3)])


Any help on this how-to validates it?.

resource.py

class CTAResource(resources.ModelResource):

 class meta: Model=CTA

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c919ad64-b4b8-4e6a-a169-5162ea62541fn%40googlegroups.com.

No comments:

Post a Comment