Changes between Initial Version and Version 6 of Ticket #34311


Ignore:
Timestamp:
Feb 5, 2023, 1:28:23 PM (22 months ago)
Author:
Willem Van Onsem
Comment:

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')]

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34311

    • Property Triage Stage UnreviewedAccepted
    • Property Summary The documentation on serialization uses unique_togetherUpdate serialization examples from unique_together to UniqueConstraint
    • Property Owner changed from nobody to Willem Van Onsem
    • Property Status newassigned
    • Property Has patch set
  • Ticket #34311 – Description

    initial v6  
    1 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.
     1The idea is thus to transform code on the page like:
    22
    3 https://docs.djangoproject.com/en/dev/topics/serialization/
     3{{{
     4class Mymodel(model):
     5      class Meta:
     6           unique_together = [[ 'field1', 'field2' ]]
     7}}}
     8
     9to:
     10
     11{{{
     12class Mymodel(model):
     13      class Meta:
     14           constraints = [models.UniqueConstraint(fields=('field1', 'field2'), name='field1_2_unique')]
     15}}}
Back to Top