Opened 8 years ago

Last modified 8 years ago

#27817 closed Bug

Jsonfield duplicating records in production database after running manage.py test — at Version 2

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 (last modified by Christian Maillefaud)

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):
     @classmethod
     def setUpTestData(self):      
            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
                        }
                    }
                )

Change History (2)

comment:1 by Christian Maillefaud, 8 years ago

Component: UncategorizedDatabase layer (models, ORM)

comment:2 by Christian Maillefaud, 8 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top