#27817: Jsonfield duplicating records in production database after running
manage.py test
-------------------------------------+-------------------------------------
Reporter: Christian | Owner: nobody
Maillefaud |
Type: Bug | Status: new
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Christian Maillefaud:
Old 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
> }
> }
> )
> }}}
New 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):
@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
}
}
)
}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/27817#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/069.3d5d786b395f98d67a735e455df1fb8e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.