Skip to content

Instantly share code, notes, and snippets.

@ryu22e
Last active September 6, 2019 01:14
Show Gist options
  • Save ryu22e/536d70391f695fb3184a8d84328773b6 to your computer and use it in GitHub Desktop.
Save ryu22e/536d70391f695fb3184a8d84328773b6 to your computer and use it in GitHub Desktop.
SQLアンチパターン for Django 1章 ジェイウォーク(信号無視)
"""悪い例"""
from django.db import models
class Product(models.Model):
name = models.CharField(max_length=1000)
account_id = models.CharField(max_length=100) # カンマ区切りでIDを入れる(例: '1,2,3')
"""良い例"""
from django.conf import settings
from django.db import models
class Product(models.Model):
name = models.CharField(max_length=1000)
account_id = models.ManyToManyField(
to=settings.AUTH_USER_MODEL,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment