title: Django , Postgres : ValueError: invalid literal for int() with base 10: ' '
body: <p>I am trying to code to webscrape some number. I get everything going  well if I try to print it on the window. The print works fine.</p>
  <p>But After I add the code to save the data into the database( postgres ) I get this error:&quot;ValueError: invalid literal for int() with base 10: ' '&quot;</p>
  <blockquote>
  <p>Models.py:</p>
  </blockquote>
  <pre><code>from django.db import models
  
  
  class Category(models.Model):
      
     
      name = models.CharField(max_length=128, unique=False)
  
      def __unicode__(self):
          return '%s' %(self.name)
  
  class Page(models.Model):
      category = models.ForeignKey(Category)
      title = models.CharField(max_length=128)
      price = models.DecimalField(decimal_places=3, max_digits=8)
      ann_hea = models.CharField(max_length=128, default='ann_headlines')
      ann_date = models.CharField(max_length=128, default ='ann_date')
      ann_det = models.CharField(max_length=128,default = 'ann_details')
      ann_ty = models.CharField(max_length=128, default='ann_type')
      multi = models.IntegerField(default=0)
      ex_da = models.CharField(max_length=128, default='date')
  
      def __unicode__(self):
          return self.title
  </code></pre>
  <p>=========================================</p>
  <blockquote>
  <p>&quot;views.py&quot;</p>
  </blockquote>
  <pre><code>    from django.shortcuts import render
      from django.http import HttpResponse
      from django.template import RequestContext
      from django.shortcuts import render_to_response
      from django.shortcuts import render
      from rango.models import Category
      from rango.models import Page
      from rango.forms import CategoryForm
      
      '''
      Code for form here.......
      
      '''
      
      '''
  getFeedContentCA(web):
  
      code to scrape web .. posting the last half for the code..
      .
      .
      .
      .
      .
          xyz = {'Title': x['Company Name'],'price': (x['Price']),'headlines':an_headlines,'Details':an_det,'type': an_ty,'multi': an_multi,'ex_da':an_ex_da,'date':an_date}
          
          return xyz  
  
  y = getFeedContentCA('https://finance.yahoo.com/')
  print (' _________________________________________ ')
  print (y['Title'])
  print (y['price'])
  print (y['hea'])
  print (y['Det'])
  print (y['ty'])
  print (y['multi'])
  print (y['ex_da'])
  print (y['date'])
  
  
  
  
  a = Category.objects.create(name=x['Name'])
  
  b = Page.objects.create(title=a, price=float(y['price']) ,ann_date=(y['date']), ann_hea=(y['hea']),ann_det=(y['Det']),ann_ty=(y['ty']),ex_da=(y['ex_da']), multi=(y['multi']))
  
  b.save()
  </code></pre>
  <p>====================================</p>
  <p>the print outputs work fine they show up on the window, but when I add the code to save data into the DB it throws that error. I tried adding 'float' datatype in the data saving to db line, it did not help.</p>
  <p>Similar error here gave the same solution of adding :</p>
  <ol>
  <li>Float data type</li>
  <li>Decimal type in the Models.py.</li>
  </ol>
  <p>Tried both.</p>
  <p>Thanks in advance!</p>
  <blockquote>
  <p>Adding the Trace error :</p>
  </blockquote>
  <pre><code>Unhandled exception in thread started by &lt;function check_errors.&lt;locals&gt;.wrapper at 0x0000000004A7C8C8&gt;
  Traceback (most recent call last):
    File &quot;C:\Python34\lib\site-packages\django\utils\autoreload.py&quot;, line 226, in wrapper
      fn(*args, **kwargs)
    File &quot;C:\Python34\lib\site-packages\django\core\management\commands\runserver.py&quot;, line 121, in inner_run
      self.check(display_num_errors=True)
    File &quot;C:\Python34\lib\site-packages\django\core\management\base.py&quot;, line 374, in check
      include_deployment_checks=include_deployment_checks,
    File &quot;C:\Python34\lib\site-packages\django\core\management\base.py&quot;, line 361, in _run_checks
      return checks.run_checks(**kwargs)
    File &quot;C:\Python34\lib\site-packages\django\core\checks\registry.py&quot;, line 81, in run_checks
      new_errors = check(app_configs=app_configs)
    File &quot;C:\Python34\lib\site-packages\django\core\checks\urls.py&quot;, line 14, in check_url_config
      return check_resolver(resolver)
    File &quot;C:\Python34\lib\site-packages\django\core\checks\urls.py&quot;, line 24, in check_resolver
      for pattern in resolver.url_patterns:
    File &quot;C:\Python34\lib\site-packages\django\utils\functional.py&quot;, line 35, in __get__
      res = instance.__dict__[self.name] = self.func(instance)
    File &quot;C:\Python34\lib\site-packages\django\urls\resolvers.py&quot;, line 313, in url_patterns
      patterns = getattr(self.urlconf_module, &quot;urlpatterns&quot;, self.urlconf_module)
    File &quot;C:\Python34\lib\site-packages\django\utils\functional.py&quot;, line 35, in __get__
      res = instance.__dict__[self.name] = self.func(instance)
    File &quot;C:\Python34\lib\site-packages\django\urls\resolvers.py&quot;, line 306, in urlconf_module
      return import_module(self.urlconf_name)
    File &quot;C:\Python34\lib\importlib\__init__.py&quot;, line 109, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 2254, in _gcd_import
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 2237, in _find_and_load
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 2226, in _find_and_load_unlocked
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1200, in _load_unlocked
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1129, in _exec
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1471, in exec_module
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 321, in _call_with_frames_removed
    File &quot;C:\Python34\test\lepnew\urls.py&quot;, line 23, in &lt;module&gt;
      url(r'^rango/', include('rango.urls'))
    File &quot;C:\Python34\lib\site-packages\django\conf\urls\__init__.py&quot;, line 50, in include
      urlconf_module = import_module(urlconf_module)
    File &quot;C:\Python34\lib\importlib\__init__.py&quot;, line 109, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 2254, in _gcd_import
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 2237, in _find_and_load
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 2226, in _find_and_load_unlocked
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1200, in _load_unlocked
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1129, in _exec
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1471, in exec_module
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 321, in _call_with_frames_removed
    File &quot;C:\Python34\test\rango\urls.py&quot;, line 18, in &lt;module&gt;
      from rango import views
    File &quot;C:\Python34\test\rango\views.py&quot;, line 280, in &lt;module&gt;
      b = Page.objects.create(title=a, price=float(y['price']) ,ann_date=(y['ex_date']), ann_headlines=(y['headlines']),ann_details=(y['Details']),ann_type=(y['type']),ex_date=(y['ex_date']), multiplier=(y['multiplier']))
    File &quot;C:\Python34\lib\site-packages\django\db\models\manager.py&quot;, line 85, in manager_method
      return getattr(self.get_queryset(), name)(*args, **kwargs)
    File &quot;C:\Python34\lib\site-packages\django\db\models\query.py&quot;, line 399, in create
      obj.save(force_insert=True, using=self.db)
    File &quot;C:\Python34\lib\site-packages\django\db\models\base.py&quot;, line 796, in save
      force_update=force_update, update_fields=update_fields)
    File &quot;C:\Python34\lib\site-packages\django\db\models\base.py&quot;, line 824, in save_base
      updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
    File &quot;C:\Python34\lib\site-packages\django\db\models\base.py&quot;, line 908, in _save_table
      result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
    File &quot;C:\Python34\lib\site-packages\django\db\models\base.py&quot;, line 947, in _do_insert
      using=using, raw=raw)
    File &quot;C:\Python34\lib\site-packages\django\db\models\manager.py&quot;, line 85, in manager_method
      return getattr(self.get_queryset(), name)(*args, **kwargs)
    File &quot;C:\Python34\lib\site-packages\django\db\models\query.py&quot;, line 1045, in _insert
      return query.get_compiler(using=using).execute_sql(return_id)
    File &quot;C:\Python34\lib\site-packages\django\db\models\sql\compiler.py&quot;, line 1053, in execute_sql
      for sql, params in self.as_sql():
    File &quot;C:\Python34\lib\site-packages\django\db\models\sql\compiler.py&quot;, line 1006, in as_sql
      for obj in self.query.objs
    File &quot;C:\Python34\lib\site-packages\django\db\models\sql\compiler.py&quot;, line 1006, in &lt;listcomp&gt;
      for obj in self.query.objs
    File &quot;C:\Python34\lib\site-packages\django\db\models\sql\compiler.py&quot;, line 1005, in &lt;listcomp&gt;
      [self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields]
    File &quot;C:\Python34\lib\site-packages\django\db\models\sql\compiler.py&quot;, line 945, in prepare_value
      value = field.get_db_prep_save(value, connection=self.connection)
    File &quot;C:\Python34\lib\site-packages\django\db\models\fields\__init__.py&quot;, line 755, in get_db_prep_save
      prepared=False)
    File &quot;C:\Python34\lib\site-packages\django\db\models\fields\__init__.py&quot;, line 747, in get_db_prep_value
      value = self.get_prep_value(value)
    File &quot;C:\Python34\lib\site-packages\django\db\models\fields\__init__.py&quot;, line 1832, in get_prep_value
      return int(value)
  ValueError: invalid literal for int() with base 10: ' '
  </code></pre>