Представление Project.views.index не возвращало объект HttpResponse. Вместо этого он вернул None

Я столкнулся с такой проблемой enter image description here

пока это мой код views.py

Создайте свои представления здесь.

          # Create your views here.
          def index(request):
              if request.method == 'POST':
                  feature1 = Feature.objects.all()
                  Appnt = Appointment.objects.all()
                  Appnt.name = request.POST['name']
                  Appnt.email = request.POST['email']
                  Appnt.phone = request.POST['phone']
                  Appnt.Adate = request.POST['date']
                  Appnt.Dept = request.POST['department']
                  Appnt.Doc = request.POST['doctor']
                  Appnt.message = request.POST['message']
                  return render(request, 'index.html', {'feature1' : feature1}, {'Appointment' : Appnt} )

Я пробовал много способов, но все равно он продолжает говорить, что ошибка

Пожалуйста, поместите оператор возврата и feature1 = Feature.objects.all() и Appnt = Appointment.objects.all() из if loop

Правильный путь

# Create your views here.
def index(request):
    feature1 = Feature.objects.all()
    Appnt = Appointment.objects.all()
    if request.method == 'POST':
        Appnt.name = request.POST['name']
        Appnt.email = request.POST['email']
        Appnt.phone = request.POST['phone']
        Appnt.Adate = request.POST['date']
        Appnt.Dept = request.POST['department']
        Appnt.Doc = request.POST['doctor']
        Appnt.message = request.POST['message']
    contaxt = {
        'feature1' : feature1,
        'Appointment' : Appnt
    }
    return render(request, 'index.html', contaxt)
Вернуться на верх