[Solved] Please I’m new to python and I’m trying to do a recipe app using Django. I encountered an error which is “UnboundLocalError: local variable form [closed]
you only create form if your request is POST. so if you try to call your view with get method form variable is not created. this is your code I’m gonna walk you through it. def register(request): if request.method == “POST”: form = UserCreationForm(request.POST) if form.is_valid(): username = form.cleaned_data.get(‘username’) messages.success(request,f”{username}, your account has been created!”) … Read more