Opened 16 years ago

Closed 16 years ago

#10894 closed (wontfix)

django.test.client.post does not throw exception when selected foreign key does not exists

Reported by: Carlos <ble.jurado@…> Owned by: nobody
Component: Uncategorized Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

client = Client()

client.post(url, {'param1': "just_a_text", 'multiselect_many2many': ('1',)})

But foreign key 1 does not exists.

Current behavior: status code 200 plus

Expected behavior: runtime exception

Change History (4)

comment:1 by Ramiro Morales, 16 years ago

Can you post a simple self-contained minimal example of what you are reporting?. currently the report is confusing and makes hard to start reviewing it. You mention a a foreign key but then the code snippet contains a multiselect_many2many bit.

comment:2 by Carlos <ble.jurado@…>, 16 years ago

Sorry,
Say the form has a ForeignKey. It gets rendered as a dropdown ('select' in html). Using django.test.client.Client.post you send a dictionary which key is the dropdown name but its value is a number which does not match any item in the foreign table.
Better now?

Thanks

comment:3 by Karen Tracey, 16 years ago

You've still completely left out the view that processes the post data. Even without that, though, I'm not understanding why your expected behavior would be a runtime exception. I wouldn't want that. Using the standard form processing formula (validate form, if it's OK do whatever is being requested and redirect to a different page otherwise re-display the existing page), what you are listing as the current behavior is correct. Why do you expect a runtime exception?

comment:4 by carlosble, 16 years ago

Resolution: wontfix
Status: newclosed

Good point mktracey. I thought this use case could not be performed through the UI as the browser does not let you pick a foreign key which is not in the rendered dropdow, but if there are several users accesing the site and one deletes the foreign key selected by the other, then you get same case which solution would be a redirect as you point. I am getting status_code 200 but I guess it is up to me to validate and get a 30x code.
Thanks :-)

Note: See TracTickets for help on using tickets.
Back to Top