Я хочу добавить git в медиа-файлы, хранящиеся django в медиа-папке. Я посмотрел на разные модули python для отслеживания медиа-файлов (gitpython, sh), но все они выдают ошибку «Отказано в доступе».Я думаю, что это проблема окружающей среды.Помощь будет оценена
def simple_upload(request):
username = None
if request.method == "POST" and request.FILES["myfile"]:
myfile = request.FILES["myfile"]
if request.user.is_authenticated:
username = request.user.username
user_dir = "/media/" + username
fs = FileSystemStorage(location="media")
fs.save(myfile.name, myfile)
if not is_git_repo(user_dir):
sh.git.init(user_dir)
rep = sh.git.bake(_cwd=user_dir)
rep.init()
rep.add(user_dir + "/" + myfile.name)
rep.commit(m="hmmm")
t = rep.head.commit.tree
print(rep.git.diff(t))
return render(request, "simple_upload.html", {"uploaded_file_url": ""})
return render(request, "simple_upload.html")