Auto assigning 2 types of user roles on sign up

59 views
Skip to first unread message

Stephanie Semerville

unread,
Oct 22, 2019, 9:38:29 PM10/22/19
to Django users
I am new to Django and trying to create a website that has two user roles primary and member. What i would like to happen is for by default a primary user to sign up and be assigned the primary role. When that primary user logs into the website, I would like them to have the ability to invite new users to the website. When that new user receives the invitation email and is redirected to the same sign up form, I would like that user to be auto assigned the member role on form submit. I have heard about the save() method but not sure how to use it and what file it goes in. Would the process change if all users can potentially be both roles?

wd

unread,
Oct 22, 2019, 11:26:19 PM10/22/19
to django...@googlegroups.com
hi,

A user could have many roles, it's all depends on your design. My understanding is:
1. When user directly sign up, he will be assigned the primary role.
2. When user sign up by an invitation, he will be assigned the member role.
3. So can a user in member role invite other users?

The 'save()' method you mentioned is the 'save' method for django models? You can simply use model class to create an instance and save it to db later.

u = User(name='Lucy')
u.save()

Maybe you can check the docs here https://docs.djangoproject.com/en/2.2/topics/db/models/ .

On Wed, Oct 23, 2019 at 9:37 AM Stephanie Semerville <Stephanie....@gmail.com> wrote:
I am new to Django and trying to create a website that has two user roles primary and member. What i would like to happen is for by default a primary user to sign up and be assigned the primary role. When that primary user logs into the website, I would like them to have the ability to invite new users to the website. When that new user receives the invitation email and is redirected to the same sign up form, I would like that user to be auto assigned the member role on form submit. I have heard about the save() method but not sure how to use it and what file it goes in. Would the process change if all users can potentially be both roles?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c80f1b02-d1e8-4a9d-a8ca-80af61260e79%40googlegroups.com.

Nazish Akhtar

unread,
Oct 23, 2019, 11:24:32 AM10/23/19
to Django users
Hey.
I am working project where I need it. Five different roles, but users can have Multiple roles. Here is link to my git repo https://github.com/noobExtendsBot/django-custom-user form out side it in not documented enough (actually haven't commit on github) but you have a look inside models it is explained well. Note: I am using 'accounts' app to manage my users as user will need mobile number to login. You may want to have a look at model.py in account app. Here is the link https://github.com/noobExtendsBot/django-custom-user/blob/master/src/accounts/models.py

Please let me know if you need any help.

Stephanie Semerville

unread,
Oct 23, 2019, 12:14:10 PM10/23/19
to Django users
When you say: "create an instance and save it to db later", is that dynamic?


On Tuesday, October 22, 2019 at 11:26:19 PM UTC-4, WD Wang wrote:
hi,

A user could have many roles, it's all depends on your design. My understanding is:
1. When user directly sign up, he will be assigned the primary role.
2. When user sign up by an invitation, he will be assigned the member role.
3. So can a user in member role invite other users?

The 'save()' method you mentioned is the 'save' method for django models? You can simply use model class to create an instance and save it to db later.

u = User(name='Lucy')
u.save()

Maybe you can check the docs here https://docs.djangoproject.com/en/2.2/topics/db/models/ .

On Wed, Oct 23, 2019 at 9:37 AM Stephanie Semerville <Stephanie...@gmail.com> wrote:
I am new to Django and trying to create a website that has two user roles primary and member. What i would like to happen is for by default a primary user to sign up and be assigned the primary role. When that primary user logs into the website, I would like them to have the ability to invite new users to the website. When that new user receives the invitation email and is redirected to the same sign up form, I would like that user to be auto assigned the member role on form submit. I have heard about the save() method but not sure how to use it and what file it goes in. Would the process change if all users can potentially be both roles?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.

Jani Tiainen

unread,
Oct 23, 2019, 12:43:44 PM10/23/19
to django...@googlegroups.com
Hi.

Personally I would do it as follows:

On invitation create invited user account at least with email and with member role. Make account disabled. You might also add invitation key which you can put in email and check as well.

When invited user starts sign up procedure you can just fill in the blanks and enable account.


ke 23. lokak. 2019 klo 4.38 Stephanie Semerville <Stephanie....@gmail.com> kirjoitti:
I am new to Django and trying to create a website that has two user roles primary and member. What i would like to happen is for by default a primary user to sign up and be assigned the primary role. When that primary user logs into the website, I would like them to have the ability to invite new users to the website. When that new user receives the invitation email and is redirected to the same sign up form, I would like that user to be auto assigned the member role on form submit. I have heard about the save() method but not sure how to use it and what file it goes in. Would the process change if all users can potentially be both roles?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Stephanie Semerville

unread,
Oct 23, 2019, 3:11:11 PM10/23/19
to Django users
Understood but what is the snippet o code that specifies the role that i would like to assign to invited user?


On Wednesday, October 23, 2019 at 12:43:44 PM UTC-4, Jani Tiainen wrote:
Hi.

Personally I would do it as follows:

On invitation create invited user account at least with email and with member role. Make account disabled. You might also add invitation key which you can put in email and check as well.

When invited user starts sign up procedure you can just fill in the blanks and enable account.


ke 23. lokak. 2019 klo 4.38 Stephanie Semerville <Stephanie...@gmail.com> kirjoitti:
I am new to Django and trying to create a website that has two user roles primary and member. What i would like to happen is for by default a primary user to sign up and be assigned the primary role. When that primary user logs into the website, I would like them to have the ability to invite new users to the website. When that new user receives the invitation email and is redirected to the same sign up form, I would like that user to be auto assigned the member role on form submit. I have heard about the save() method but not sure how to use it and what file it goes in. Would the process change if all users can potentially be both roles?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages