Issue #152 new

Fix QuerySet filtering on

k0001 avatark0001 created an issue

By default, the method takes a **kwargs argument that is handled to the QuerySet.filter method so that one can get filtered results from a Handler. However, this is ignored when we looking for a single object (i.e., looking for a particular pk) instead of a collection, which is inconsistent.

I made some changes (with tests) in so that:

  • A single object lookup happens on the already-filtered QuerySet, making it consistent with a collection lookup.
  • Getting a MultipleObjectsReturned exception when looking for a single object doesn't return rc.BAD_REQUEST anymore. That's an unexpected model design error the programer is responsible for; a 500 is more apropiate.

Additionaly, I've added the follwing enhacement:

  • Single object lookups can be done using either the name of the primary key field, or pk (i.e., provided id is the name of the primary key: kwargs={'pk': '1'} and kwargs={'id': '1'} give the same results).

Comments (0)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.