Skip to content

get() returned more than one FormModelData #31

Description

@dcale

I keep getting this error if I submit a form more than once:

MultipleObjectsReturned at /form/test/done/
get() returned more than one FormModelData -- it returned 11!

The issue happens because of the following code:

       try:
            display_key = self.request.GET.get('display_key')
            data = FormModelData.objects.get(display_key=display_key)
            context.update({
                'data': data,
            })
        except FormModelData.DoesNotExist:
            pass

The issue is fixed if one uses FormModelData.objects.filter(display_key=display_key).all()[0]. But this feels more like a hotfix/hack, because the issue lies deeper, you expect that display_key is unique, which is not the case if the same guy submits twice.

The other fix would be to except all exception and simply pass...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions