#34311: Update serialization examples from unique_together to UniqueConstraint
-------------------------------------+-------------------------------------
Reporter: Willem Van Onsem | Owner: Willem
Type: | Van Onsem
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Old description:
> Documentation on serialization uses `unique_together`, whereas it seems
> to be advised to use Django's constraint framework. Therefore this might
> introduce confusion. Perhaps we should "update" the documentation.
>
> https://docs.djangoproject.com/en/dev/topics/serialization/
New description:
The idea is thus to transform code on the page like:
{{{
class Mymodel(model):
class Meta:
unique_together = [[ 'field1', 'field2' ]]
}}}
to:
{{{
class Mymodel(model):
class Meta:
constraints = [models.UniqueConstraint(fields=('field1',
'field2'), name='field1_2_unique')]
}}}
--
Comment (by Willem Van Onsem):
The idea is thus to transform code on the page like:
{{{
class Mymodel(model):
class Meta:
unique_together = [[ 'field1', 'field2' ]]
}}}
to:
{{{
class Mymodel(model):
class Meta:
constraints = [models.UniqueConstraint(fields=('field1',
'field2'), name='field1_2_unique')]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34311#comment:6>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070186230d0d48-a9728b85-2a95-48e5-b839-2c3c046afcf7-000000%40eu-central-1.amazonses.com.