Не сохраняется форма в админку
forms.py
def main_page(request):
if request.method == 'POST':
reservation = UserReservationForm(request.POST)
if reservation.is_valid():
reservation.save()
return redirect('/')
class UserReservation(models.Model):
mobile_regex = RegexValidator(regex='^(\d{3}[- .]?){2}\d{4}$', message='Phone format in xxx xxx xxxx')
name = models.CharField(max_length=50, unique=True, db_index=True)
email = models.EmailField(max_length=250)
phone = models.CharField(max_length=15, validators=[mobile_regex])
message = models.TextField(max_length=500, blank=True)
date = models.DateTimeField(auto_now_add=True)
is_processed = models.BooleanField(default=False)
models.py