I have a model named "db_connector" and another one "project_site".
A "project_site" can have many to many relation with "db-connector". But the "project_site" should have one default db-connector.
What is the best design-pattern for this? Can I combine many to many and one to one like this: Many to many relation for alternative connectors linked to a project_site and one to one for the default connector linked to a project_site?
The user can specify a db_connector, if the user doesn't specify a database_conector, the default db_connector can be used?
Using this pattern on django causes an error (fields.E305)
Project_site.alternative_db_connectors: (fields.E305) Reverse query name for 'Project_site.alternative_db_connectors' clashes with reverse query name for 'Project_site.default_db_connector'. HINT: Add or change a related_name argument to the definition for 'Project_site.alternative_db_connectors' or 'Project_site.default_db_connector'.
The project_site models looks like this:
class Project_site(models.Model):
name = models.CharField(max_length=150)
project_group = models.ForeignKey(Project_Group, on_delete=models.CASCADE)
default_db_connector = models.OneToOneField(DB_Connector, on_delete=models.CASCADE , primary_key=True ,)
alternative_db_connectors = models.ManyToManyField(DB_Connector)
def __str__(self) -> str:
return self.name
In SQL terms it should be possible, right?