I'll like to know, why I'm getting "invalid literal for int() with base 10 error" but works pretty well in the interactive mode?
我想知道,为什么我得到“基础10错误的int()的无效文字”,但在交互模式下工作得很好?
fees = {u'nid':u'179', u'type':u'fees', u'jamb_no': u'01234SS'}
for fee in fees:
# Transaction model
try:
txn = Transaction()
txn.nid = int(fee.get(u'nid'))
txn.type = options.get(u'type')
txn.jamb_no = fee.get(u'jamb_no') # invalid literal for int() with base 10
txn.save()
Models.py
class Transaction(models.Model):
id = models.AutoField(primary_key=True)
type = models.CharField(max_length=50)
nid = models.IntegerField()
jamb_no = models.CharField(max_length=20, blank=False)
Traceback:
追溯:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\celery-2.3.2-py2.7.egg\celery\execute\trace.py"
, line 36, in trace
return cls(states.SUCCESS, retval=fun(*args, **kwargs))
File "C:\Python27\lib\site-packages\celery-2.3.2-py2.7.egg\celery\app\task\__init__
.py", line 232, in __call__
return self.run(*args, **kwargs)
File "C:\Python27\lib\site-packages\celery-2.3.2-py2.7.egg\celery\app\__init__.py",
line 172, in run
return fun(*args, **kwargs)
File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\transaction.py",
line 217, in inner
res = func(*args, **kwargs)
File "api\tasks.py", line 142, in queue_transaction
ValueError: invalid literal for int() with base 10: '01234SS'
on the interactive prompt, this works pretty well
在交互式提示上,这非常有效
>>> fees = {u'jamb_no': u'01234SS'}
>>> fees.get(u'jamb_no')
u'01234SS'
>>>
>>> jamb_no = u'01234SS'
>>> str(jamb_no)
'01234SS'
Please help me. I've been on this for 2 days.
请帮帮我。我已经在这2天了。
1 个解决方案
#1
0
The problem has to do with celery. When I make changes to tasks.py, celery need to be restarted. This I didn't do, which obviously is causing a repetitive error messages even when the state has changed.
这个问题与芹菜有关。当我对tasks.py进行更改时,需要重新启动芹菜。我没有这样做,这显然导致重复的错误消息,即使状态已经改变。
#1
0
The problem has to do with celery. When I make changes to tasks.py, celery need to be restarted. This I didn't do, which obviously is causing a repetitive error messages even when the state has changed.
这个问题与芹菜有关。当我对tasks.py进行更改时,需要重新启动芹菜。我没有这样做,这显然导致重复的错误消息,即使状态已经改变。