1
0
mirror of https://github.com/django/django.git synced 2025-02-22 07:24:59 +00:00
Mariusz Felisiak 0379e7532f [5.0.x] Applied Black's 2024 stable style.
https://github.com/psf/black/releases/tag/24.1.0

Backport of 305757aec19c9d5111e4d76095ae0acd66163e4b from main
2024-01-26 12:55:56 +01:00

28 lines
683 B
Python

"""
Many-to-many and many-to-one relationships to the same table
Make sure to set ``related_name`` if you use relationships to the same table.
"""
from django.db import models
class User(models.Model):
username = models.CharField(max_length=20)
class Issue(models.Model):
num = models.IntegerField()
cc = models.ManyToManyField(User, blank=True, related_name="test_issue_cc")
client = models.ForeignKey(User, models.CASCADE, related_name="test_issue_client")
class Meta:
ordering = ("num",)
def __str__(self):
return str(self.num)
class StringReferenceModel(models.Model):
others = models.ManyToManyField("StringReferenceModel")