This is my new approach.
But it does not work as expected;
When I close the page and restart the development server, it works perfectly fine for the first time. But after that it does not work. I surely don't have any idea about what's going one.
class homeView(View):
def get(self, request):
data = recipemeal.objects.all().order_by("-id")
context ={
"recipes":data,
"form":RecipeForm()
}
return render(request, "index.html", context)
def post(self, request):
form = RecipeForm(request.POST)
if form.is_valid():
form.save()
data = recipemeal.objects.all().order_by("-id")
context = {
"recipes": data,
"form": RecipeForm()
}
return render(request, "index.html", context)