Question: I'm using django to do a pixel tracker on an email

Is it easy to return an actual image from a django view (and how would this be done?) or is it easier to just return a redirect to the url where the actual image lives?

Answer: 
You don't need an actual image for a tracker pixel. In fact, it's better if you don't have one.

Just use the view as the source for the image tag, and have it return a blank response.
**Python2.x:**

```
from django.http import HttpResponse

PIXEL_GIF_DATA = """
R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
""".strip().decode('base64')

def pixel_gif(request):
    return HttpResponse(PIXEL_GIF_DATA, content_type='image/gif')

```

**Python3.x:**

```
import base64
from django.http import HttpResponse

PIXEL_GIF_DATA = base64.b64decode(
    b"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")

def pixel_gif(request):
    return HttpResponse(PIXEL_GIF_DATA, content_type='image/gif')

```

**Source:** <https://gist.github.com/simonw/10235798>