You could pass the filtering criteria as a dict and avoid repeating the `Notice.objects.filter()..` call.

    if request.GET.get('all', False):
        criteria = {
            'directory__pootle_path__startswith': directory.pootle_path,
        }
    else:
        criteria = {
            'directory': directory,
        }

And then, out of any `if`/`else` branch:

    template_vars.update({
        'notices': Notice.objects.filter(**criteria).select_related('directory')[:30],
    })