ValueError:int()的无效文字,带有基数为10的django.setup()

时间:2015-10-17 15:41:28

标签: python django python-2.7 django-models

我最初的问题是models not loaded yet,不知怎的,我从stackoverflow获得了django.setup()解决问题的信息。但是当我使用django.setup()时,我得到了这个错误:

ValueError: invalid literal for int() with base 10

这是我的追溯

Traceback (most recent call last):
  File "C:/Users/Samson/Documents/searchengine/SearchEngine/Scripts/lens/lens/crawler.py", line 110, in <module>
    spider.crawl_web()
  File "C:/Users/Samson/Documents/searchengine/SearchEngine/Scripts/lens/lens/crawler.py", line 66, in crawl_web
    objListing.save() #save to database
  File "C:\Python27\Lib\site-packages\django\db\models\base.py", line 591, in save
    force_update=force_update, update_fields=update_fields)
  File "C:\Python27\Lib\site-packages\django\db\models\base.py", line 619, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "C:\Python27\Lib\site-packages\django\db\models\base.py", line 681, in _save_table
    forced_update)
  File "C:\Python27\Lib\site-packages\django\db\models\base.py", line 711, in _do_update
    filtered = base_qs.filter(pk=pk_val)
  File "C:\Python27\Lib\site-packages\django\db\models\query.py", line 691, in filter
    return self._filter_or_exclude(False, *args, **kwargs)
  File "C:\Python27\Lib\site-packages\django\db\models\query.py", line 709, in _filter_or_exclude
    clone.query.add_q(Q(*args, **kwargs))
  File "C:\Python27\Lib\site-packages\django\db\models\sql\query.py", line 1287, in add_q
    clause, require_inner = self._add_q(where_part, self.used_aliases)
  File "C:\Python27\Lib\site-packages\django\db\models\sql\query.py", line 1314, in _add_q
    current_negated=current_negated, connector=connector)
  File "C:\Python27\Lib\site-packages\django\db\models\sql\query.py", line 1186, in build_filter
    condition = self.build_lookup(lookups, col, value)
  File "C:\Python27\Lib\site-packages\django\db\models\sql\query.py", line 1094, in build_lookup
    return final_lookup(lhs, rhs)
  File "C:\Python27\Lib\site-packages\django\db\models\lookups.py", line 82, in __init__
    self.rhs = self.get_prep_lookup()
  File "C:\Python27\Lib\site-packages\django\db\models\lookups.py", line 85, in get_prep_lookup
    return self.lhs.output_field.get_prep_lookup(self.lookup_name, self.rhs)
  File "C:\Python27\Lib\site-packages\django\db\models\fields\__init__.py", line 646, in get_prep_lookup
    return self.get_prep_value(value)
  File "C:\Python27\Lib\site-packages\django\db\models\fields\__init__.py", line 915, in get_prep_value
    return int(value)
ValueError: invalid literal for int() with base 10: '5617c8f4b705960e4c314406'

Process finished with exit code 1

感谢

1 个答案:

答案 0 :(得分:2)

这与django.setup()无关。错误发生在crawl_web中:您正在尝试使用整数字段保存项目,但为其提供值“5617c8f4b705960e4c314406”,这不是整数。