当前位置: 首页>>代码示例>>Python>>正文


Python Normal.save方法代码示例

本文整理汇总了Python中hvad.test_utils.project.app.models.Normal.save方法的典型用法代码示例。如果您正苦于以下问题:Python Normal.save方法的具体用法?Python Normal.save怎么用?Python Normal.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hvad.test_utils.project.app.models.Normal的用法示例。


在下文中一共展示了Normal.save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_normal

# 需要导入模块: from hvad.test_utils.project.app.models import Normal [as 别名]
# 或者: from hvad.test_utils.project.app.models.Normal import save [as 别名]
 def create_normal(self, data, translations=None):
     obj = Normal(shared_field=data.shared_field)
     for code in translations or self.translations:
         obj.translate(code)
         obj.translated_field = data.translated_field[code]
         obj.save()
     return obj
开发者ID:jqb,项目名称:django-hvad,代码行数:9,代码来源:fixtures.py

示例2: test_create_instance_translated_nolang

# 需要导入模块: from hvad.test_utils.project.app.models import Normal [as 别名]
# 或者: from hvad.test_utils.project.app.models.Normal import save [as 别名]
 def test_create_instance_translated_nolang(self):
     with LanguageOverride('en'):
         obj = Normal(language_code='en', translated_field = "English")
         obj.save()
         en = Normal.objects.language('en').get(pk=obj.pk)
         self.assertEqual(en.translated_field, "English")
         self.assertEqual(en.language_code, "en")
开发者ID:kohout,项目名称:django-hvad,代码行数:9,代码来源:basic.py

示例3: test_create_instance_shared_nolang

# 需要导入模块: from hvad.test_utils.project.app.models import Normal [as 别名]
# 或者: from hvad.test_utils.project.app.models.Normal import save [as 别名]
 def test_create_instance_shared_nolang(self):
     with translation.override('en'):
         obj = Normal(language_code='en', shared_field = "shared")
         obj.save()
         en = Normal.objects.language('en').get(pk=obj.pk)
         self.assertEqual(en.shared_field, "shared")
         self.assertEqual(en.language_code, "en")
开发者ID:bforchhammer,项目名称:django-hvad,代码行数:9,代码来源:basic.py

示例4: test_create_instance_shared_nolang

# 需要导入模块: from hvad.test_utils.project.app.models import Normal [as 别名]
# 或者: from hvad.test_utils.project.app.models.Normal import save [as 别名]
 def test_create_instance_shared_nolang(self):
     with LanguageOverride("en"):
         obj = Normal(language_code="en", shared_field="shared")
         obj.save()
         en = Normal.objects.language("en").get(pk=obj.pk)
         self.assertEqual(en.shared_field, "shared")
         self.assertEqual(en.language_code, "en")
开发者ID:randomknowledge,项目名称:django-hvad,代码行数:9,代码来源:basic.py

示例5: test_create_instance_both

# 需要导入模块: from hvad.test_utils.project.app.models import Normal [as 别名]
# 或者: from hvad.test_utils.project.app.models.Normal import save [as 别名]
 def test_create_instance_both(self):
     obj = Normal(language_code="en", shared_field="shared", translated_field="English")
     obj.save()
     en = Normal.objects.language("en").get(pk=obj.pk)
     self.assertEqual(en.shared_field, "shared")
     self.assertEqual(en.translated_field, "English")
     self.assertEqual(en.language_code, "en")
开发者ID:randomknowledge,项目名称:django-hvad,代码行数:9,代码来源:basic.py

示例6: test_filtered_get

# 需要导入模块: from hvad.test_utils.project.app.models import Normal [as 别名]
# 或者: from hvad.test_utils.project.app.models.Normal import save [as 别名]
 def test_filtered_get(self):
     obj = Normal(shared_field='field_1')
     obj.translate('en')
     obj.translated_field = 'field_2'
     obj.save()
     qs = Normal.objects.language('en') | Normal.objects.language('de')
     found = qs.filter(shared_field='field_1').get(pk=obj.pk)
     self.assertEqual(found.pk, obj.pk)
开发者ID:kohout,项目名称:django-hvad,代码行数:10,代码来源:basic.py

示例7: test_create_instance_simple

# 需要导入模块: from hvad.test_utils.project.app.models import Normal [as 别名]
# 或者: from hvad.test_utils.project.app.models.Normal import save [as 别名]
 def test_create_instance_simple(self):
     obj = Normal(language_code='en')
     obj.shared_field = "shared"
     obj.translated_field = "English"
     obj.save()
     en = Normal.objects.language('en').get(pk=obj.pk)
     self.assertEqual(en.shared_field, "shared")
     self.assertEqual(en.translated_field, "English")
     self.assertEqual(en.language_code, "en")
开发者ID:kohout,项目名称:django-hvad,代码行数:11,代码来源:basic.py

示例8: test_translated_foreignkey_set

# 需要导入模块: from hvad.test_utils.project.app.models import Normal [as 别名]
# 或者: from hvad.test_utils.project.app.models.Normal import save [as 别名]
    def test_translated_foreignkey_set(self):
        cache = Related._meta.translations_cache

        normal = Normal(language_code='en')
        normal.save()
        related = Related(language_code='en')
        related.translated = normal
        self.assertNotIn('translated_id', related.__dict__)
        self.assertIn('translated_id', getattr(related, cache).__dict__)
        self.assertEqual(getattr(related, cache).__dict__['translated_id'], normal.pk)

        related.translated_id = 4242
        self.assertNotIn('translated_id', related.__dict__)
        self.assertIn('translated_id', getattr(related, cache).__dict__)
        self.assertEqual(getattr(related, cache).__dict__['translated_id'], 4242)
开发者ID:bforchhammer,项目名称:django-hvad,代码行数:17,代码来源:basic.py


注:本文中的hvad.test_utils.project.app.models.Normal.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。