Remove explicit lookup_field from all ViewSet#308
Merged
brianhelba merged 1 commit intomasterfrom Mar 3, 2026
Merged
Conversation
DRF `ViewSet` defaults to using `lookup_field = "pk"`, which is Django's general pointer to any `Model`'s primary key field. Overriding `lookup_field = "id"` is unnecessary, makes the usage of DRF more surprising and less idiomatic, and introduces Ruff A002 (`builtin-argument-shadowing`) violations (where the `id` parameter shadows a Python builtin).
Deploying geodatalytics with
|
| Latest commit: |
3abeaf4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8e5a4687.geodatalytics.pages.dev |
| Branch Preview URL: | https://remove-redundant-lookup-fiel.geodatalytics.pages.dev |
annehaley
approved these changes
Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DRF
ViewSetdefaults to usinglookup_field = "pk", which is Django's general pointer to anyModel's primary key field.Overriding
lookup_field = "id"is unnecessary, makes the usage of DRF more surprising and less idiomatic, and introduces Ruff A002 (builtin-argument-shadowing) violations (where theidparameter shadows a Python builtin).