ambient-innovation / ambient-toolbox

Helpers and tools for Python and web-development with Django
https://pypi.org/project/ambient-toolbox/
MIT License
8 stars 4 forks source link

Add feature for safely accessing related attributes #27

Open robinzachmann opened 2 months ago

robinzachmann commented 2 months ago

The problem

foo = Foo.objects.all().get()
foo.bar  # <-- this will silently cause a sub-query
foo = Foo.objects.all().get()
foo.bar  # <-- this will silently cause a sub-query

Idea

Create a function for safely accessing foo.bar which complains if the attribute would cause an extra query.