def import_(request): if request.method == "GET": return {} file = request.FILES['file'] zipfile = ZipFile(file) hierarchy = import_zip(zipfile) url = hierarchy.get_absolute_url() url = '/' + url.lstrip('/') # sigh return HttpResponseRedirect(url)
def import_(request): if request.method == "GET": return render(request, "main/import.html", {}) file = request.FILES["file"] zipfile = ZipFile(file) hierarchy = import_zip(zipfile) url = hierarchy.get_absolute_url() url = "/" + url.lstrip("/") # sigh return HttpResponseRedirect(url)
def import_(request): if request.method == "GET": return render(request, "main/import.html", {}) file = request.FILES['file'] zipfile = ZipFile(file) hierarchy = import_zip(zipfile) url = hierarchy.get_absolute_url() url = '/' + url.lstrip('/') # sigh return HttpResponseRedirect(url)
def import_zipfile(zipfile): hierarchy = import_zip(zipfile) transaction.commit() return hierarchy
def import_zipfile(zipfile): with transaction.atomic(): hierarchy = import_zip(zipfile) return hierarchy