views.py 776 B

12345678910111213141516171819
  1. from django.shortcuts import render
  2. from django.contrib import messages
  3. from django.http import HttpResponseRedirect
  4. from design_template.utils import handle_uploaded_file
  5. from design_template.forms import LogoForm
  6. from core import settings
  7. def upload(request):
  8. if request.method == 'POST':
  9. form = LogoForm(request.POST, request.FILES)
  10. if form.is_valid():
  11. name_system = request.POST['namesystem']
  12. settings.NAME_SYSTEM = name_system
  13. handle_uploaded_file(request.FILES['logo'])
  14. messages.success(request, "The logo has been uploaded successfully.")
  15. return HttpResponseRedirect("/admin")
  16. else:
  17. form = LogoForm()
  18. return render(request,"admin/upload_logo.html",{'form':form})