Я делаю веб -приложение с несколькими страницами. На одной из страниц я хотел бы иметь форму, которая выглядит примерно так
https://i.sstatic.net/wsoj6.jpg
Однако я продолжаю получать сообщение об ошибке с надписью: < /p>
Поднимите Crispyerror ('| as_crispy_field Неверное или
dusistentive Field ') crispy_forms.exceptions.crispyerror:
| as_crispy_field получила недействительную или неспособную поле
[10 /Jul /2019 23:21:12] "Get /Год22 Http/1.1 "500 148042
Вот мой годы2.html, который, по -видимому, происходит, где возникает ошибка:
{% extends "HelloDjangoApp/layout.html" %}
{% load crispy_forms_tags %}
**HelloDjangoApp/year2.html**
{% block content %}
{% csrf_token %}
{{ form.name|as_crispy_field }}
{{ form.email|as_crispy_field }}
{{ form.job_title|as_crispy_field }}
{{ form.bio|as_crispy_field }}
Calculate
{% endblock %}
< /code>
Для контекста, вот мой представление.
from django.shortcuts import render
from django.http import HttpResponse
from datetime import datetime
from django.shortcuts import render # Added for this step
from django.views.generic import CreateView
from .models import Person
class PersonCreateView(CreateView):
model = Person
fields = ('name', 'email', 'job_title', 'bio')
def index(request):
now = datetime.now()
return render(
request,
"HelloDjangoApp/index.html", # Relative path from the 'templates' folder to the template file
# "index.html", # Use this code for VS 2017 15.7 and earlier
{
'title' : "Exam Results Calculator",
'message' : "Hello!",
'content' : " on " + now.strftime("%A, %d %B, %Y at %X"),
}
)
def about(request):
return render(
request,
"HelloDjangoApp/about.html",
{
'title' : "Simply enter your scores to find out your average",
'content' : "Example app page for Django."
}
)
def year1(request):
return render(
request,
"HelloDjangoApp/year1.html",
{
'title' : "1st Year Average",
'content' : "First Year Stuff"
}
)
def year2(request):
return render(
request,
"HelloDjangoApp/year2.html",
{
'title' : "2nd Year Average",
'content' : "Second Year Stuff"
}
)
def year3(request):
return render(
request,
"HelloDjangoApp/year3.html",
{
'title' : "3rd Year Average",
'content' : "3rd Year Stuff"
}
)
def year4(request):
return render(
request,
"HelloDjangoApp/year4.html",
{
'title' : "4th Year Average",
'content' : "4th Year Stuff"
}
)
# Create your views here.
< /code>
и мои модели.py < /p>
from django.db import models
# Create your models here.
class Person(models.Model):
name = models.CharField(max_length=130)
email = models.EmailField(blank=True)
job_title = models.CharField(max_length=30, blank=True)
bio = models.TextField(blank=True)
Подробнее здесь: https://stackoverflow.com/questions/569 ... istent-fie
Как мне справиться с сообщением об ошибке «| AS_CRISPY_FIELD. ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Наследует help_text из django.db.models.Field в rest_framework.serializer.Field
Anonymous » » в форуме Python - 0 Ответы
- 70 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Наследует help_text из django.db.models.Field в rest_framework.serializer.Field
Anonymous » » в форуме Python - 0 Ответы
- 75 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Наследует help_text из django.db.models.Field в rest_framework.serializer.Field
Anonymous » » в форуме Python - 0 Ответы
- 65 Просмотры
-
Последнее сообщение Anonymous
-