@permission_required("core.manage_shop")
def manage_categories(request):
    """Dispatches to the first category or to the add category form if no
    category exists yet.
    """
    try:
        category = Category.objects.all()[0]
    except __HOLE__:
        url = reverse("lfs_manage_no_categories")
    else:
        url = reverse("lfs_manage_category", kwargs={"category_id": category.id})

    return HttpResponseRedirect(url)
dataset/ETHPy150Open diefenbach/django-lfs/lfs/manage/categories/category.py/manage_categories