Reputation: 42768
For index_together
, I was wondering, should I use tuple
or list
, as both seems workable.
class ApiMonthlyUsage(models.Model):
month = models.IntegerField(blank=False, null=False)
count = models.IntegerField()
user = models.ForeignKey(User, on_delete=models.CASCADE)
class Meta:
index_together = (
('month', 'user'),
)
class ApiMonthlyUsage(models.Model):
month = models.IntegerField(blank=False, null=False)
count = models.IntegerField()
user = models.ForeignKey(User, on_delete=models.CASCADE)
class Meta:
index_together = [
['month', 'user'],
]
Upvotes: 1
Views: 119
Reputation: 365945
The only objective answer here is to give you a list of the common arguments each way:
But it’s up to you to decide how much you agree with each of these and how much weight to give them.
But really, as long as you pick one or the other and use it consistently in your project, your code will be perfectly readable to any other Python developer, so I wouldn’t stress too much. If you really can’t decide, flip a coin and get on with it.
Upvotes: 3