D
D
Dmitry2019-06-04 21:44:07
Django
Dmitry, 2019-06-04 21:44:07

I wrote a registration on django, but I enter the data and nothing happens, what's the problem?

I wrote a registration on django, but I enter the data and nothing happens, tell me what's the problem?
Logic Code

from django.shortcuts import render, redirect
from django.contrib.auth.forms import UserCreationForm
from django.contrib import messages

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} был успешно создан!')
            return redirect('blog-home')
     else:
        form = UserCreationForm()
     return render(request, 'users/registration.html', {'form': form, 'title': 'Регистрация пользователя'})

Registration page code
{% extends 'blog/main.html'%}
 {% block main_sections %}
 <div class="form-sections">
     <h2>Регистрация на сайте</h2>
     <form method="POST">
         {% csrf_token %}
         {{ form.as_p }}
         <button type="submit" class="btn btn-outline-warning">Зарегистрироваться</button>
     </form>
  </div>
 {% endblock main_sections %}


 {% block aside_news_sections %}
   <h3><b>10 фактов о вашем здоровье</b></h3>
   <img src="https://news.tut.by/society/640246.html" class="img-thumbnail mb-1">
   <p>Когда начинаешь заботится о свой здоровье то понимаешь многое. Представляем вам 10 фактов о вашем здоровье</p>
   <a href="https://news.tut.by/society/640246.html" target="_blank">
       <button class="btn btn-warning">Посмотреть</button>
   </a>
 {% endblock aside_news_sections %}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem, 2019-06-04
@ulkoart

no form.save()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question