Question: I am using a android project as a lib whose Activity's manifest says:

```
<activity
        android:name="pay.CardActivity"
        android:configChanges="keyboardHidden|orientation" />

```

In CardActivity onOrientationChanged() is overrriden and there is rotation logic written in it.

I want to lock the CardActivity to portrait always from my main project. I tried doing 

```
<activity
    android:name="pay.CardActivity"
    android:screenOrientation="portrait" /> 

```

But that did not lock the orientation. Is there a way to do this? CardActivity is final, so I cannot extend and override its onOrientationChanged() method.

Answer: 
You can do that by accessing the reverse `ForeignKey` field from Role. Something like:

```
if role_instance.userprofile_set.all():
   print "Care, role is related to userprofile instances"
else:
   print "You are safe to go" 

```
I think you are expecting this

```
role = Role.objects.get(name_role="rolename")
role.user_profile_set.all() #check if any before delete

```

Try this also 

```
role.userprofile_set.all()

```