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

Can I add django-organizations to a Rest API project? #212

Closed rakshit9 closed 2 years ago

rakshit9 commented 3 years ago

I also facing the same Issues Is there any way to use?

asencis commented 3 years ago

Short answer - yes - we've added it successfully. Just like any other model we've created. There are certain some caveats and gotchas for using it, but we're very happy with picking this solution.

Cataldir commented 3 years ago

I came to open an issue about this, so I'll update this one.

The major problem in this implementation is the BaseBackend, which enforces the usage of a form instead of allowing (perhaps guessing?) if the application uses rest framework or not.

I think we should update the BaseBackend to include the possibility of a Rest Framework application, by removing all the forms variables and creating a FormBaseBackend and a SerializerBaseBackend, or either implementing a check if rest framework is installed or a setting option (probably a list) allowing both usages of forms and serializers.

If you agree, I might be able to upload an update on this issue in the next 15 days

bennylope commented 3 years ago

@Cataldir, the short answer is yes!

Regardless of the solution, it would be better to be explicit, such that it works as expected for current users (providing a form class by default, for example), and allowing a serializer class instead. Guessing based on installed apps could have unintended effects.

Since I presume you're talking about the invitations/registration, a totally separate or parallel set of backends classes would be another option. It might be more lines of code, but would probably allow for simpler development, testing, and end-user extenadability. What you think?