Django - ValueError: invalid literal for int() with base 10: 'E-Mail Bestätigen'
Ich bekomme immer diese Fehlermeldung und für das Leben von mir ich kann nicht finden, die Quelle des Problems.
Traceback:
/Library/Python/2.7/site-packages/django/core/handlers/base.py in get_response
response = middleware_method(request)
/Library/Python/2.7/site-packages/django/middleware/common.py in process_request
if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
/Library/Python/2.7/site-packages/django/core/urlresolvers.py in is_valid_path
resolve(path, urlconf)
/Library/Python/2.7/site-packages/django/core/urlresolvers.py in resolve
return get_resolver(urlconf).resolve(path)
/Library/Python/2.7/site-packages/django/core/urlresolvers.py in resolve
for pattern in self.url_patterns:
/Library/Python/2.7/site-packages/django/core/urlresolvers.py in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
/Library/Python/2.7/site-packages/django/core/urlresolvers.py in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
/Library/Python/2.7/site-packages/django/utils/importlib.py in import_module
__import__(name)
/Users/user/Desktop/user/urls.py in <module>
import contacts.views
/Users/user/Desktop/contacts/views.py in <module>
import forms
/User/Desktop/contacts/forms.py in <module>
class ContactForm(forms.ModelForm):
/Users/Desktop/contacts/forms.py in ContactForm
required=True,
Bin ich auf die effektive django tutorials und in diesem Seite, aber ich kann nicht vorbei an den E-Mail-überprüfung Abschnitt. Ich bin mir nicht genau sicher, was mache ich hier falsch.
Forms.py:
from django import forms
from django.core.exceptions import ValidationError
from contacts.models import Contact
class ContactForm(forms.ModelForm):
confirm_email = forms.EmailField(
"Confirm email",
required=True,
)
class Meta:
model = Contact
def __init__(self, *args, **kwargs):# Constructor mutates kwarg.
if kwargs.get('instance'):
email = kwargs['instance'].email# Instance is the name of what's being edited
kwargs.setdefault('initial', {})['confirm_email'] = email
return super(ContactForm, self).__init__(*args, **kwargs)
def clean(self):
if (self.cleaned_data.get('email') !=
self.cleaned_data.get('confirm_email')):
raise ValidationError(
"Email address must match."
)
return self.cleaned_data
Modelle:
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
email = models.EmailField()
def __str__(self):
return ' '.join([
self.first_name,
self.last_name,
])
def get_absolute_url(self):
return reverse('contacts-view', kwargs={'pk': self.id})#Returns address of a contact.
- Poste bitte die traceback-für Ihre Fehler
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ändern
confirm_email
Schlüsselwort-Argumente:Weil, wenn Sie es definieren als:
Den Konstruktor von
forms.EmailField
bekamConfirm email
alsmax_length
: