1
私はdjangoでいくつかのことを試しています。データベースにログインしようとするすべての試みを追加する簡単なフォーム。 ValueError:基数10のint()の無効なリテラル:多くの質問をチェックアウトしましたが、このエラーを回避できませんでした。Django:ValueError:基数10のint()のリテラルが無効です:
私はこのような見解を持っています。
class LoginView(TemplateView):
template_name = 'dashboard/login.html'
def post(self,request):
#firstname,email=request.POST['firstname'],request.POST['email']
#currLogin = LoginForm(firstname,email)
currLogin = LoginForm(request.POST)
if currLogin.is_valid():
firstname= currLogin.cleaned_data['firstname']
email = currLogin.cleaned_data['email']
print firstname,email
users = LoginModel.objects.filter(email=email)
if not users:
login = LoginModel(firstname,email)
login.save()
else :
return users[0].id
return 0
マイmodels.pyファイルが含まれています:
class LoginModel(models.Model):
firstname = models.CharField(max_length=100)
email = models.CharField(max_length=100)
私form.pyはこれを含んでいます
class LoginForm(forms.Form):
firstname = forms.CharField(label="firstname",max_length=100)
email = forms.CharField(label="email",max_length=100)
class Meta:
model = LoginModel
スタックトレース:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py", line 88, in dispatch
return handler(request, *args, **kwargs)
File "/home/akshay/Downloads/mindwave/dashboard/views.py", line 27, in post
login.save()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 796, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 824, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 889, in _save_table
forced_update)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 919, in _do_update
filtered = base_qs.filter(pk=pk_val)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 796, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 814, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 1227, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 1253, in _add_q
allow_joins=allow_joins, split_subq=split_subq,
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 1187, in build_filter
condition = self.build_lookup(lookups, col, value)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 1083, in build_lookup
return final_lookup(lhs, rhs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/lookups.py", line 19, in __init__
self.rhs = self.get_prep_lookup()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/lookups.py", line 59, in get_prep_lookup
return self.lhs.output_field.get_prep_value(self.rhs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 946, in get_prep_value
return int(value)
ValueError: invalid literal for int() with base 10: 'Ak
これを把握内の任意のヘルプアウトは高く評価されます。
スタックトレース全体を共有できますか? – Bonifacio2
完全なトレースバックを共有します。エラーはどの行に表示されますか? –
htmlページのフォームフィールドにはどのような値を入力していますか? –