Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok so I think you're trying to go from auth.User.username to ShibUser to do this follow the ForeignKeys backwards:</p> <pre><code>user = User.objects.get(username=username) # for reverse relationships the foo_set is created by django enabling # reverse relationship. You can override this by providing a related_name shibuser = user.shibuser_set.get() # Alternative syntax shibuser = user.shibuser_set.all()[0] </code></pre> <p>From there you can get your ShibUser role. If More than one ShibUser can exist per User then you want to drop the index and will instead have a queryset of ShibUser objects to work with.</p> <p>If only one ShibUser object can exist per User you should make this a OneToOneField instead of a foreignkey and things become simpler:</p> <pre><code>shibuser = user.shibuser </code></pre> <p>Finally you can even start from the ShibUser model and work with it:</p> <pre><code>shibuser = ShibUser.objects.get(auth_user__username=username) # Or if you already had the User object instance shibuser = ShibUser.objects.get(auth_user=user) </code></pre> <p>Keep in mind several exceptions can be raised around this depending on the approach: the User could not exist or the ShibUser for the given User could not exist. Perhaps more than one ShibUser could be related to a single user and therefore the .get() calls will result in a <code>MultipleObjectsReturned</code> exception. Your schema isn't very tight to your use case it sounds like so I would probably improve that with a OneToOneField</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload