Opened 7 years ago

Closed 7 years ago

#27817 closed Bug (needsinfo)

Jsonfield duplicating records in production database after running manage.py test

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 (3)

comment:1 by Christian Maillefaud, 7 years ago

Component: UncategorizedDatabase layer (models, ORM)

comment:2 by Christian Maillefaud, 7 years ago

Description: modified (diff)

comment:3 by Tim Graham, 7 years ago

Resolution: needsinfo
Status: newclosed

Hi, the description doesn't indicate an obvious problem with Django. I'm doubtful I'll be able to reproduce this given the information you provided. The problem seems more likely related to your settings. I'd suggest to put together a minimal sample project that reproduces the issue and ask for help debugging it on our support channels. Or, if you can debug the issue yourself, please reopen with an explanation of why Django is at fault. Thanks.

Note: See TracTickets for help on using tickets.
Back to Top