-
-
Notifications
You must be signed in to change notification settings - Fork 165
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
Custom INVITATION_MODEL
with unique_together fields
#203
Comments
This happened to me because I had messy migrations because of the multiple trials. Drop the DB tables of the previous invitations tables (under your app or the django-invitations app) and it should work later |
The same thing happened to me! It seems the problem is, that even when you are setting your invitation model via. INVITATIONS_INVITATION_MODEL, invitation.Invitation is NOT excluded from the migration. After adding this modelfield I was able to create the migration file:
But when running |
You can prevent the migrations from being installed by: https://docs.djangoproject.com/en/dev/ref/settings/#migration-modules MIGRATION_MODULES = {
"invitations": None,
} But the problem is it screws up In theory this shouldn't make a difference, running through the migrations or simply using the models to build up the DB, but it feels wrong to be forced into this position. |
The best would be to exclude The next best would be to allow both classes to coexist without overwriting class AbstractBaseInvitation(models.Model):
[...]
inviter = models.ForeignKey(
settings.AUTH_USER_MODEL,
null=True,
blank=True,
on_delete=models.CASCADE,
related_name="%(app_label)s_%(class)ss",
related_query_name="%(app_label)s_%(class)s",
[...] |
* [#203] Add related_name to avoid conflicts when subclassing. * Add tests for invitation related_name and related_query_name --------- Co-authored-by: blag <[email protected]>
I'm working on a multi-tenant app using django-tenants and django-tenant-users, the custom user model is build around this abstract model.
Everything works great.
Now I need to implement invitations, but in my case, the invitations should be unique by email+tenant because a user can be invited to the system and to different tenants (I would figure the logic to make this happen in the future).
So I tried to create a custom
INVITATION_MODEL
this way:users/models.py
:Pretty much the same as the default model but just adding the extra tenant field.
Added the
INVITATION_MODEL
to the settings.I tried
manage.py migrate
and/ormanage.py makemigration
but I get this error:Any idea how can I fix it? Or you know a better approach (or lib) to implement invitations in a multi-tenancy app?
The text was updated successfully, but these errors were encountered: