Wednesday, October 23, 2019

Re: Auto assigning 2 types of user roles on sign up

Initially you will have to create Role object and then assign it to user. and you add new roles whenever you want by editing Role model

On Wednesday, 23 October 2019 21:44:10 UTC+5:30, Stephanie Semerville wrote:
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c80f1b02-d1e8-4a9d-a8ca-80af61260e79%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/db86a016-27ae-43d0-aa17-1e5f05c25c89%40googlegroups.com.

No comments:

Post a Comment