jwjacobson / jazztunes

a jazz repertoire management app
https://jazztunes.org
GNU General Public License v3.0
4 stars 1 forks source link

Make if/else POST slightly cleaner #16

Closed bbelderbos closed 11 months ago

bbelderbos commented 11 months ago
          sorry I need to update my example, but I find this cleaner / more explicit:
def tune_new(request):
    if request.method == "POST":
        form = TuneForm(request.POST)
        if form.is_valid():
            form.save()
            messages.success(request, 'Added tune')
            return redirect('tune:tune_list')
    else:
        form = TuneForm()

    return render(request, 'tune/form.html', {'form': form})

(so not using the or None)

_Originally posted by @bbelderbos in https://github.com/jwjacobson/jazz_repertoire/pull/13#discussion_r1403594952_

jwjacobson commented 11 months ago

I will implement this, but is the idea that it's cleaner because it doesn't have the or in the form declaration?

bbelderbos commented 11 months ago

Of course subjective, but I like the if/else a bit more explicit and more readable. Not urgent though.