djangogirls
djangogirls copied to clipboard
IntegrityError: duplicate key value violates unique constraint "applications_application_form_id_b47c846a_uniq"
Sentry Issue: DJANGO-GIRLS-WEBSITE-43
UniqueViolation: duplicate key value violates unique constraint "applications_application_form_id_b47c846a_uniq"
DETAIL: Key (form_id, email)=(675, ) already exists.
File "django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
IntegrityError: duplicate key value violates unique constraint "applications_application_form_id_b47c846a_uniq"
DETAIL: Key (form_id, email)=(675, ) already exists.
(12 additional frame(s) were not displayed)
...
File "django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
def save(self, *args, **kwargs):
application = Application.objects.create(form=self.form)
This seems to be related to this line, in ApplicationForm
we initially create an application for that form_id
with no e-mail. Afterwards, we loop through question types and assign an e-mail to the application.
According to code, it looks like there could be forms that don't require e-mails, but I wonder if we accept applications without an e-mail? Maybe instead of calling objects.create
we can just instantiate an Application
record and save it when we post process the forms questions and answers?