Skip to content
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

Cannot use forms or views with single-table customized organization models #191

Open
bareynol opened this issue Jan 30, 2020 · 4 comments
Open

Comments

@bareynol
Copy link

I have created custom organization, organization user, and organization owner models using the abstract organization models

The "Getting Started" sections of the docs say this about single-table customized organization models:

If however you want to use single-table customized organization models and/or custom organization user models, it may be best to treat Django organizations as a library and not install it in your Django project. See the Advanced customization using abstract models section.

However, forms.py and views.py both import the Organization model from organizations.models, which causes this error:

Django Version: | 2.2.9
-- | --
RuntimeError
Model class organizations.models.Organization doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

I'm currently just copying the forms.py and views.py code over to my app, but is there a better way to accomplish being able to use those utilities without having organizations installed as an app?

@joshuachinemezu
Copy link

My solution: Fork the project and make your desired changes :)

@xmnlab
Copy link

xmnlab commented Jun 2, 2022

I am not super familiar with the code base, but I guess that one of the problems is here:

return create_organization(

create_organization should be able to add extra parameters for the custom model.

@LucidDan
Copy link

I ran into this issue too.

The problem is more fundamental than just passing parameters - you'd need to sub the model in the Meta for each Form class, etc. And not import the Organization models directly anywhere in the code, otherwise it errors.

It probably needs to follow the swappable model pattern to make this work, I think? (eg like described/supported in https://github.com/openwisp/django-swappable-models)

In the short term, I think the "Cooking with" documentation should at least be updated so people don't butt their heads into this issue unexpectedly (like I did). Happy to put together a PR for that some time in the next little while (and a PR for how swappable models could work too, but that'll take longer ;-) )

@bennylope
Copy link
Owner

Happy to put together a PR for that some time in the next little while

That would be welcomed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants