Почему не выводится форма django?
Вот файл forms.py:
from django import forms
from django.forms import ModelForm
from .models import User
class UserForm(forms.ModelForm):
class Meta:
model = User
fields = ['name_user', 'email_user', 'password']
Вот файл models.py:
from django.db import models
import datetime
from django.utils import timezone
# Create your models here.
class Trailer(models.Model):
name_trailer = models.CharField("Название трейлера", max_length=200)
pub_date = models.DateTimeField('Дата публикации трейлера', default=timezone.now())
trailer = models.FileField(upload_to='videos/', null=True, verbose_name="")
class User(models.Model):
name_user = models.CharField("Name", max_length=50)
email_user = models.EmailField('Email')
password = models.CharField('Password', max_length=50)
data_create_user = models.DateTimeField('Account creation date', default=timezone.now())
Вот файл views.py:
from django.shortcuts import render
from .forms import UserForm
from django.contrib.auth import authenticate, login
def index(request):
return render(request, 'polls/index.html')
def trailers(request):
return render(request, 'polls/trailers.html')
def about(request):
return render(request, 'polls/about.html')
def login(request):
return render(request, 'polls/login.html')
def registration(request):
return render(request, 'polls/registration.html')
def post_new(request):
form = UserForm()
data = {
'form': form
}
return render(request, 'polls/registration.html', data)
И вот файл registration.html:
<div class="registration_form">
<h1>Регистрация</h1>
<form class="form_registration" method="post">
{% csrf_token %}
{{ form.as_ul }}
<label>Введите ваше имя пользователя:</label><br>
<input name="user_user" id="user_username" placeholder="Ваше имя" value="{{ current_name }}" required><br>
<label>Введите вашу почту:</label><br>
<input name="user_email" type="email" id="user_email" placeholder="Ваша почта" value="{{ current_email }}" required><br>
<label>Введите ваш пароль:</label><br>
<input name="user_pass" type="password" id="user_pass" placeholder="Ваш пароль" required><br>
<input name="user_submit" type="submit" id="user_submit" value="Зарегистрироваться">
</form>
</div>