Skip to content

Commit

Permalink
Add comment explaining if statement
Browse files Browse the repository at this point in the history
This if statement returns true if the function is the same as ModelView.
It will return false if the user has overridden the function in their
own class.

The if statement surrounds the relationships for loop since, if they
have overridden the function to filter relationships, we don't want to
add all of the relationships back in afterwards.
  • Loading branch information
lukeclimen committed Apr 15, 2024
1 parent d2e999f commit f357d47
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions sqladmin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ async def get_object_for_edit(self, request: Request) -> Any:
stmt = self.form_query(request)

if type(self).form_query == ModelView.form_query:
# If form_query fn hasn't been overridden, add all relationships
for relation in self._form_relations:
stmt = stmt.options(joinedload(relation))

Expand Down

0 comments on commit f357d47

Please sign in to comment.