Posts

Showing posts from December 17, 2018

Django form with IntegrityError exception

Image
up vote 0 down vote favorite I would like to get your help in order to use except IntegrityError in my formset . I have my model file : class Document(models.Model): code = models.CharField(max_length=25, verbose_name=_('code'), unique=True, null=False, blank=False, default='') language = models.CharField(max_length=2, verbose_name=_('language'), choices=LANGUAGE_CHOICES) format = models.CharField(max_length=10, verbose_name=_('format'), choices=FORMAT_CHOICES) title = models.CharField(max_length=512, verbose_name=_('title')) publication = models.ForeignKey(Publication, verbose_name=_('publication title'), related_name='documents') upload = models.FileField(upload_to='media/', validators=[validate_file_extension], verbose_name=_('