[Fixed]-Django Custom Admin Form bulk save implmentation

1👍

You should just add the super().save() to the the end of the function:

def save(self, *args, commit=True, **kwargs):
    try:
        company = self.cleaned_data['company']
        records = csv.reader(self.cleaned_data['file_to_import'])
        for line in records:
            # Get CSV Data.

            # Create new employee.
            employee = CreateEmployee(...)
        super().save(*args, **kwargs)
    except Exception as e:
        raise forms.ValidationError('Something went wrong.')

Leave a comment