def post(self, request): """edit the site settings""" site = models.SiteSettings.objects.get() form = forms.SiteForm(request.POST, request.FILES, instance=site) if not form.is_valid(): data = {"site_form": form} return TemplateResponse(request, "settings/site.html", data) site = form.save() data = {"site_form": forms.SiteForm(instance=site), "success": True} return TemplateResponse(request, "settings/site.html", data)
def get(self, request): ''' edit form ''' site = models.SiteSettings.objects.get() data = { 'title': 'Site Settings', 'site_form': forms.SiteForm(instance=site) } return TemplateResponse(request, 'settings/site.html', data)
def post(self, request): """ edit the site settings """ site = models.SiteSettings.objects.get() form = forms.SiteForm(request.POST, instance=site) if not form.is_valid(): data = {"site_form": form} return TemplateResponse(request, "settings/site.html", data) form.save() return redirect("settings-site")
def post(self, request): ''' edit the site settings ''' site = models.SiteSettings.objects.get() form = forms.SiteForm(request.POST, instance=site) if not form.is_valid(): data = {'title': 'Site Settings', 'site_form': form} return TemplateResponse(request, 'settings/site.html', data) form.save() return redirect('settings-site')
def get(self, request): """edit form""" site = models.SiteSettings.objects.get() data = {"site_form": forms.SiteForm(instance=site)} return TemplateResponse(request, "settings/site.html", data)