в django, когда я собираюсь импортировать CSV-файл и анализировать его, я получаю следующее сообщение об ошибке
django.db.utils.IntegrityError: Сбой ограничения NOT NULL: inven_app_clientcontact.author_id
[29 / Apr / 2019 17:56:32] «POST / контакты / импорт HTTP / 1.1» 500 188071
вот мой код
@login_required
def contact_upload(request):
template = 'site/contact_upload.html'
prompt = {
'order': 'Order of the CSV should be client_name, client_company_name, email, work_phone'
}
if request.method == 'GET':
return render(request, template, prompt)
csv_file = request.FILES['file']
if not csv_file.name.endswith('.csv'):
messages.error(request, 'This is not a csv file')
data_set = csv_file.read().decode('utf-8')
io_string = io.StringIO(data_set)
next(io_string)
for column in csv.reader(io_string, delimiter=',', quotechar='|'):
_, created = ClientContact.objects.filter(author=request.user).update_or_create(
client_name=column[0],
client_company_name=column[1],
email=column[2],
work_phone=column[3]
)
context = {}
return render(request, template, context)
любая помощь будет оценена. Спасибо. Если какой-либо код необходим, пожалуйста, дайте мне знать