I am trying to write a script which I intend to use in a scheduled fashion.
This script is not part of the django project, but communicates with it.

The script stars like

```
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings")
from django.db.models import Q
from app.models import *

transactions = Transaction.objects.filter(Q(paypal_auth != None)
    and Q(paypal_auth.payer_id != None))

```

Now the problem is the output of the python console:

```
AttributeError: module 'app.models.paypal_auth' has no attribute 'payer_id'

```

So why is this happening?

**Thanks to @daniel, this is my solution:**

```
transactions = Transaction.objects.filter(~Q(paypal_auth__payment_id=None)
    & ~Q(paypal_auth__payer_id=None))

```