Customer既存の顧客 (モデル ) が選択して表示できるWeb サイトに新しいセクションを作成しています。
新しいユーザーは、メイン サイト ( Customer) からアカウントを取得する必要はなく、新しいセクション (NewSecUserモデル)のアカウントを作成するだけで済みます。
class Customer(models.Model):
name = models.CharField(max_length=50)
#[...]
is_visible_on_new_section = models.BooleanField(default=False)
class NewSecUser(model.Model):
name = models.CharField(max_length=50)
#[...]
customer_id = models.IntegerField(null=True)
# customer_id refers to the id of a Customer model object
# its value is different from null only when a Customer chooses to appear
# on the new section
オブジェクトが に等しく、に設定されているオブジェクトを除外するには、どのように使用exclude()しますか? NewSecUserCustomeridNewSecUser.customer_idis_visible_on_new_sectionFalse
JOIN基本的には SQL ( with ) に似たものだとnew_sec_user.customer_id=customer.id思います。
外部キーの方がはるかに簡単だったことはわかっていcustomer_idますが、これを選択しませんでした。