Python django.db.utils 模块,DataError() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用django.db.utils.DataError()

项目:CoBL-public    作者:lingdb    | 项目源码 | 文件源码
def populate_from_bibtex(self, bibtex_dict):
        for key in bibtex_dict.keys():
            if key not in ['ID', 'date']:
                setattr(self, key, bibtex_dict[key])
        try:
            self.save()
        except DataError as e:
            print(e, bibtex_dict)
项目:rets-django    作者:bgirer    | 项目源码 | 文件源码
def handle_listing(listing_object, results_item):
        try:
            new_listing_object = extract_listing_data(results_item)
            updated_listing_object = update_core_listing_data(listing_object,
                                                              new_listing_object)
            updated_listing_object.save()
        except (ValueError, DataError, PG_DataError):
            logger.debug(traceback.print_exc(limit=None))
            raise ListingException()


# Handle premature exits
项目:babar3    作者:Babaritech    | 项目源码 | 文件源码
def test_message_short_enough(self):
        """
        Test that a message length can't be superior to 140 characters
        """
        t = Tweet(
            time = 60,
            message = 't'*141
        )
        # assertRaises doesn't seem to work
        try:
            t.save()
        except Exception as e:
            self.assertTrue(type(e) is DataError)
项目:django_postgres_extensions    作者:primal100    | 项目源码 | 文件源码
def test_array_int_raises(self):
        self.assertRaises(DataError, self.queryset.update, prices=ArrayAppend('prices', 'test'))