Answer the question
In order to leave comments, you need to log in
Error: AttributeError: 'NoneType' object has no attribute 'split'. What's the matter?
Let's start with the fact that I'm a beginner. I created a simple form for sending data to the database on the site. Everything sends well, but this error constantly comes up (a lot of text and at the end AttributeError: 'NoneType' object has no attribute 'split'. )
It occurs already when the server starts after a few seconds.
view:
from django.shortcuts import render
from .forms import PersonForm
from django.http import HttpResponse, HttpResponseRedirect
#Create your views here.
def index(request):
form = PersonForm (request.POST or None)
if request.method == "POST" and form.is_valid():
form.save()
return render(request, "index.html", {'form': form})
from django.db import models
# Create your models here.
class Person(models.Model):
name = models.CharField(max_length=20,verbose_name='Имя')
email = models.EmailField(verbose_name='E-mail')
tel = models.CharField(max_length=12,verbose_name='Телефон')
class Meta:
verbose_name = u'Пользователь'
verbose_name_plural = u'Пользователи'
from django import forms
from .models import Person
class PersonForm (forms.ModelForm):
class Meta:
model = Person
exclude = [""]
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Присоединиться">
</form>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question