bennylope / django-organizations

:couple: Multi-user accounts for Django projects
http://django-organizations.readthedocs.org/
BSD 2-Clause "Simplified" License
1.31k stars 212 forks source link

UUID instead of int OR --> RuntimeError: Model class organizations.models.Organization doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS. #183

Closed apowell656 closed 5 years ago

apowell656 commented 5 years ago

All I want to do is use a UUID instead of an int for PK. After reading how to use customized models and seeing this issue to know it can be done I am unable to make or apply migrations.

I have the following structure: myApp |_models |organizations | init.py |_ models.py etc.

And models.py has the following:

` import uuid from django.db import models from organizations.abstract import (AbstractOrganization, AbstractOrganizationOwner, AbstractOrganizationUser)

class Organization(AbstractOrganization): id = models.UUIDField(default=uuid.uuid4(), editable=False, primary_key=True)

class Meta:
    app_label = 'myApp'

class OrganizationOwner(AbstractOrganizationOwner): id = models.UUIDField(default=uuid.uuid4(), editable=False, primary_key=True)

class Meta:
    app_label = 'myApp'

class OrganizationUser(AbstractOrganizationUser): id = models.UUIDField(default=uuid.uuid4(), editable=False, primary_key=True)

class Meta:
    app_label = 'myApp' `

When running makemigrations the following error is produced: RuntimeError: Model class organizations.models.Organization doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

I am just trying to use UUIDs instead of simple ids in my app. What am I missing? Previously, I was able to override a view with no issue, and now I just want to create my own tables, etc.

apowell656 commented 5 years ago

My solution fork the project and make the changes. I guess this is a workaround, but I believe the documentation could/should be a little clearer on how to accomplish this.