from django.shortcuts import render, redirect from .models import Tourist def index(request): if request.method == 'POST': name = request.POST.get('name') email = request.POST.get('email') emergency_contact_name = request.POST.get('emergency_contact_name') emergency_contact_phone = request.POST.get('emergency_contact_phone') if name and email and emergency_contact_name and emergency_contact_phone: if not Tourist.objects.filter(email=email).exists(): Tourist.objects.create( name=name, email=email, emergency_contact_name=emergency_contact_name, emergency_contact_phone=emergency_contact_phone ) return redirect('registration_success') return render(request, 'core/index.html') def registration_success(request): return render(request, 'core/registration_success.html')