How can I generate a query_set through a linked model?
For example, how can I do this:
UserProfile.objects.filter(user.is_active=True) # Can't use user.is_active to filter
A trivial question, a trivial answer. But I will keep it here for posterity.
UserProfile.objects.filter(user__is_active=True)
This is well documented in Django docs.
From a Django Document
Django offers a powerful and intuitive way to "keep track" of relationships in a search, taking care of SQL JOINs for you automatically, behind the scenes. To encompass relationships, simply use the field name of related fields in different models, separated by double underscores, until you get to the field you want.
In your example, this would be:
The easiest way to track relationships is to use a simple "__".
UserProfile.objects.filter (user__is_active = True)
They can also be changed together (i.e. user_parent_email = ' abc@def.com )
Source: https://habr.com/ru/post/896822/More articles:Does the browser provide reflection if the position of an element is absolute? - performanceIs it possible to simulate the keyboard shortcut Ctrl + F using jQuery? - javascriptbuilding the top 5 values from a table in R - rhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/896820/find-all-ways-to-sum-given-number-with-repetitions-allowed-from-given-set&usg=ALkJrhivXFEDbYYAPCE0evQcdXOOgR_XBAhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/896821/is-there-an-upper-limit-to-the-number-of-commits-a-git-repository-can-handle&usg=ALkJrhiWJ8kG1KdNQdF-ng8DMKtqvh78-AChecking if row data has changed - databaseProviding math equations in Android - androidRails 3 Restrict access so that the user can only update their data - ruby-on-rails-3Does SQLAlchemy support "close tables"? - pythonCreating an animated gif using the GD library - phpAll Articles