Created
January 10, 2011 11:08
-
-
Save rob-b/772645 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: %psource Tiger | |
class Tiger(models.Model): | |
call = models.CharField(max_length=255, blank=True) | |
In [2]: tony = Tiger() | |
In [3]: tony.call = u'Grrrreeeeeeeeaaaaaatttt' | |
In [4]: tony.save() | |
In [5]: tony.call = None | |
In [6]: tony.save() | |
--------------------------------------------------------------------------- | |
IntegrityError Traceback (most recent call last) | |
/home/rob/python/someproject/someproject/<ipython console> in <module>() | |
/home/rob/.virtualenvs/animal/lib/python2.6/site-packages/django/db/models/base.pyc in save(self, force_insert, force_update, using) | |
454 if force_insert and force_update: | |
455 raise ValueError("Cannot force both insert and updating in model saving.") | |
--> 456 self.save_base(using=using, force_insert=force_insert, force_update=force_update) | |
457 | |
458 save.alters_data = True | |
/home/rob/.virtualenvs/animal/lib/python2.6/site-packages/django/db/models/base.pyc in save_base(self, raw, cls, origin, force_insert, force_update, using) | |
520 if force_update or non_pks: | |
521 values = [(f, None, (raw and getattr(self, f.attname) or f.pre_save(self, False))) for f in non_pks] | |
--> 522 rows = manager.using(using).filter(pk=pk_val)._update(values) | |
523 if force_update and not rows: | |
524 raise DatabaseError("Forced update did not affect any rows.") | |
/home/rob/.virtualenvs/animal/lib/python2.6/site-packages/django/db/models/query.pyc in _update(self, values) | |
495 query.add_update_fields(values) | |
496 self._result_cache = None | |
--> 497 return query.get_compiler(self.db).execute_sql(None) | |
498 _update.alters_data = True | |
499 | |
/home/rob/.virtualenvs/animal/lib/python2.6/site-packages/django/db/models/sql/compiler.pyc in execute_sql(self, result_type) | |
864 related queries are not available. | |
865 """ | |
--> 866 cursor = super(SQLUpdateCompiler, self).execute_sql(result_type) | |
867 rows = cursor and cursor.rowcount or 0 | |
868 is_empty = cursor is None | |
/home/rob/.virtualenvs/animal/lib/python2.6/site-packages/django/db/models/sql/compiler.pyc in execute_sql(self, result_type) | |
730 | |
731 cursor = self.connection.cursor() | |
--> 732 cursor.execute(sql, params) | |
733 | |
734 if not result_type: | |
/home/rob/.virtualenvs/animal/lib/python2.6/site-packages/django/db/backends/util.pyc in execute(self, sql, params) | |
13 start = time() | |
14 try: | |
---> 15 return self.cursor.execute(sql, params) | |
16 finally: | |
17 stop = time() | |
/home/rob/.virtualenvs/animal/lib/python2.6/site-packages/django/db/backends/sqlite3/base.pyc in execute(self, query, params) | |
198 query = self.convert_query(query) | |
199 try: | |
--> 200 return Database.Cursor.execute(self, query, params) | |
201 except Database.IntegrityError, e: | |
202 raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] | |
IntegrityError: animal_tiger.call may not be NULL | |
In [7]: tony.call = u'' | |
In [8]: tony.save() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment