I am a beginner in django, and am having some trouble inputting form data to database. I am getting a
`TypeError at /Info/
Info() got an unexpected keyword argument 'email'`
when I feel I am doing it correctly Here is my models.py
from django.db import models
# Create your models here.
class Info(models.Model):
address = models.CharField(max_length=70)
email = models.EmailField(max_length=32)
My Views.py
def Info(request):
if request.method == 'POST':
form = InfoForm(request.POST)
if form.is_valid():
address = request.POST.get('address')
email = request.POST.get('email')
Facts = Info(email = email)
Facts.save()
else:
form = InfoForm()
return render(request, 'index/index.html', {'title': 'Info'})
def index(request):
return render(request, 'index/index.html', {'title': 'Home'})
My Forms.py
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class InfoForm(forms.Form):
address = forms.CharField()
email = forms.EmailField()
Thanks. Any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire