def update_webradio(request, id_webradio): selected_webradio = get_object_or_404(Webradio, id=id_webradio) form = WebradioForm(request.POST or None, instance=selected_webradio) if form.is_valid(): form.save() return redirect('webgui.views.webradio') return render(request, 'update_webradio.html', {'form': form, 'radio': selected_webradio})
def update_webradio(request, id_webradio): selected_webradio = get_object_or_404(Webradio, id=id_webradio) form = WebradioForm(request.POST or None, instance=selected_webradio) if form.is_valid(): form.save() return redirect('webgui.views.webradio') return render(request, 'update_webradio.html', { 'form': form, 'radio': selected_webradio })
def addwebradio(request): if request.method == 'POST': # If the form has been submitted... form = WebradioForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # save web radio form.instance.selected = False form.save() return redirect('webgui.views.webradio') else: form = WebradioForm() return render(request, 'addwebradio.html', {'form': form})