-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RelatedObjectDoesNotExist: Organization has no owner #190
Comments
That definitely does not sound right. django-organizations/tests/test_utils.py Lines 22 to 38 in c6ead20
That function creates the owner right at the end. django-organizations/organizations/utils.py Lines 109 to 112 in c6ead20
Before I dig further, could you share how you're calling that function and what models you're using? |
Organization models from hashid_field import HashidAutoField
from organizations.abstract import (
AbstractOrganization,
AbstractOrganizationOwner,
AbstractOrganizationUser,
)
class Organization(AbstractOrganization):
id = HashidAutoField(primary_key=True)
class OrganizationUser(AbstractOrganizationUser):
pass
class OrganizationOwner(AbstractOrganizationOwner):
pass Organization creation on user sign up import logging
from allauth.account.signals import user_signed_up
from django.dispatch import receiver
from organizations.utils import create_organization
from ninjads.organizations.models import Organization
logger = logging.LoggerAdapter(logging.getLogger(), extra={})
@receiver(user_signed_up)
def create_default_organization(
request, user, **kwargs
): # pylint: disable=unused-argument
logger.info("User %s signed up, creating a default organization", user)
create_organization(user, user.email, is_active=True, model=Organization) |
Please check my comment here |
I'm using the helper function to create a default organization when a user signs up.
django-organizations/organizations/utils.py
Lines 55 to 63 in c6ead20
The docstring says:
However the first user doesn't in fact seem to be the organization owner:
The member and admin checks succeed:
The text was updated successfully, but these errors were encountered: