You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to add django-organizations to a nascent project and it looks like it should do nearly exactly what I want except for one thing. I'm using a sub-classed OrganizationUser model from OrganizationUserBase. The relation between the org, owner, and user in the database is specified in terms of organization_id, and organization_user_id regardless of the name of my subclassed objects and regardless of what I put for default_related_name in model meta. I poked around this projects code and it looks like there are a few places that might rely on explicitly having these relationships named like this - I'm wondering how necessary is this? Is it something that could be changed? If I manually foreign key my models together using a different name than the one provided how much functionality will break?
Example:
class Lab(OrganizationBase, TimestampBase, UUIDBase):
name = models.CharField(max_length=255, help_text=_("What is the lab's name?"))
class Meta(TimestampBase.Meta):
db_table = "lab"
default_related_name = "lab"
verbose_name = _("lab")
verbose_name_plural = _("labs")
class LabUser(OrganizationUserBase, TimestampBase, UUIDBase):
email = models.EmailField(
blank=True, default="", help_text=_("What is the user's email address?")
)
class Meta(TimestampBase.Meta):
db_table = "lab_user"
default_related_name = "lab_user"
verbose_name = _("lab user")
verbose_name_plural = _("lab users")
class LabOwner(OrganizationOwnerBase, TimestampBase, UUIDBase):
class Meta(TimestampBase.Meta):
db_table = "lab_owner"
default_related_name = "lab_owner"
verbose_name = _("lab owner")
results in a database schema where lab_owner has a foreign key named organization_id and organization_user_id.
This isn't a deal breaker, but it makes it more difficult to use the database directly because my app doesn't embrace the concept of organizations.
The text was updated successfully, but these errors were encountered:
I poked around this projects code and it looks like there are a few places that might rely on explicitly having these relationships named like this - I'm wondering how necessary is this?
Strictly speaking, I don't think it's absolutely necessary. We'd just need to be able to introspect the related name.
Is it something that could be changed?
Yes, I do think so. And provided it was not backwards incompatible it would be a welcome addition. Is it something you'd have interest in writing a PR for?
Yes, I do think so. And provided it was not backwards incompatible it would be a welcome addition. Is it something you'd have interest in writing a PR for?
Very much so. I haven't had a chance to make material process on the project that would require this change but I should be (re-)beginning work soon and assuming that this is still useful to me I'll take a crack at making the above change.
I'm trying to add
django-organizations
to a nascent project and it looks like it should do nearly exactly what I want except for one thing. I'm using a sub-classed OrganizationUser model fromOrganizationUserBase
. The relation between the org, owner, and user in the database is specified in terms oforganization_id
, andorganization_user_id
regardless of the name of my subclassed objects and regardless of what I put fordefault_related_name
in model meta. I poked around this projects code and it looks like there are a few places that might rely on explicitly having these relationships named like this - I'm wondering how necessary is this? Is it something that could be changed? If I manually foreign key my models together using a different name than the one provided how much functionality will break?Example:
results in a database schema where lab_owner has a foreign key named organization_id and organization_user_id.
This isn't a deal breaker, but it makes it more difficult to use the database directly because my app doesn't embrace the concept of organizations.
The text was updated successfully, but these errors were encountered: