Opened 8 years ago
Last modified 8 years ago
#27817 closed Bug
Jsonfield duplicating records in production database after running manage.py test — at Initial Version
Reported by: | Christian Maillefaud | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.10 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Model:
class PermissionTemplate(models.Model): site = models.ForeignKey( Site, verbose_name=_("site"), on_delete=models.CASCADE, related_name="%(app_label)s_%(class)s_site" ) on_site = CurrentSiteManager() name = models.CharField(_("nome"), max_length=30) values = JSONField()
Code in TestCase:
class TestPermission(TestCase): self.site, created = Site.objects.get_or_create( defaults={ 'domain': 'testserver' }, id=settings.SITE_ID) self.permission_template, created = \ PermissionTemplate.on_site.get_or_create( site=self.site, name='test_template', defaults={ 'values': { 'open_imovel': 1, 'named_imovel': 3, 'sharing': 0, 'owner_data': 0, 'aggrements': 0, 'users': 0, 'internal': True, 'default': True } } )
Note:
See TracTickets
for help on using tickets.