L
L
LeMar2019-06-29 18:00:39
Django
LeMar, 2019-06-29 18:00:39

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})

model:
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'Пользователи'

forms.py :
from django import forms
from .models import Person


class PersonForm (forms.ModelForm):
    class Meta:
        model = Person
        exclude = [""]

index.html
<form action="" method="post">
    {% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Присоединиться">
</form>

Help, pliz, what does this get out, and how to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question