@permission_required("core.manage_shop")
def add_attachment(request, product_id):
    product = lfs_get_object_or_404(Product, pk=product_id)
    if request.method == "POST":
        for file_content in request.FILES.getlist("files[]"):
            attachment = ProductAttachment(product=product, title=file_content.name[:50])
            attachment.file.save(file_content.name, file_content, save=True)

    # Refresh positions
    for i, attachment in enumerate(product.attachments.all()):
        attachment.position = (i + 1) * 10
        attachment.save()

    product_changed.send(product, request=request)
    return manage_attachments(request, product_id)
Type-casting to ``bool``.
dataset/ETHPy150Open diefenbach/django-lfs/lfs/manage/product/attachments.py/add_attachment--crossover with--dataset/ETHPy150Open sublee/elo/elo.py/Rating.__nonzero__