Answer the question
In order to leave comments, you need to log in
Registration by invite code?
Good afternoon toaster!! There was a goal to create invitations to the site. I made an invitation model with the following fields: email, user(who invites), code(invite code), is_accept(whether the invite is accepted). The invitation code is added at the end of the sent link in the invitation.
Question: how to set up the link in url.py so that it can work and if the code is and is not?
Example:
When you go to /register/, a registration form appears.
When you go to /register/some_invite_code/, a registration form appears and is_accept = True is entered into the database.
Answer the question
In order to leave comments, you need to log in
I solved the problem like this:
I made two pages:
url(r'^register/(?P<invite_code>[A-Za-z]+)/$', views.InviteRegisterFormView.as_view(),
name='invite_register'),
url(r'^register/$', views.RegisterFormView.as_view(),
name='register'),
invite_code = self.kwargs['invite_code']
invite = get_object_or_404(UserInvite, code=invite_code)
invite.is_accept = True
invite.save()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question