I am making a new section on a website where existing customers (Customer model) can choose to appear on.
New users are not required to have an account from the main site (Customer) and can just create an account for the new section (NewSecUser model)
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
How would one use exclude() to filter-out NewSecUser objects where Customer objects have an id equal to NewSecUser.customer_id and is_visible_on_new_section set to False?
Basically something similar to an SQL JOIN (with new_sec_user.customer_id=customer.id) I believe.
I know it would have been much easier with customer_id being a foreign key but I did not choose this.
or something very similar