Not using foreign keys directly

When working with foreign keys, accessing the related field will result in a database read. That can be eliminated by using *_id, which is the foreign key value that Django has already cached on the object to make this scenario more efficient.

If our GitHub code review bot spots this issue in your pull request it gives this advice:

django-doctorbotsuggested changes just now
tasks.py
1
+
def trigger_tasks(queryset):
2
+
    for item in queryset:
3
+
        run_async_task(item.page.id)

When working with foreign keys, accessing the related field will result in a database read. That can be eliminated by using *_id, which is the foreign key value that Django has already cached on the object to make this scenario more efficient.

Read more
Suggested changes
-
        run_async_task(item.page.id)
+
        run_async_task(item.page_id)
Commit suggestion
Update tasks.py

Instantly check if you have this issue for free

    Works with tools you use

    Read about how it works.