Sunday, February 2, 2014

Re: Custom User

Many thanks Russell, it really make sense.

Cheers

-Henrique

On Sunday, February 2, 2014 8:58:59 PM UTC-2, Russell Keith-Magee wrote:
Hi Henrique,

Think of it this way: you have a site, and each person visiting your site, regardless of whether they're an admin or a member, will have a username, password, and a name. This common information is what you put in your user model. That way, everyone who visits your site and has an account (of any kind) can log in, and they're all using the same User model.

A subset of those users - the members - will then have a Profile. This profile describes the specific details of their membership (I don't know the specifics for your case, but this could be things like the expiry date for their membership, or their address for correspondence). Only member users will have a profile. 

You put a flag on the user model that describes is_admin; this tells you whether the user has admin access. Whenever you want to know "is this user a member", you can look for their membership profile. If it exists, they're a member; if it doesn't, they're not. 

Interestingly, this allows you to have admin users who are also members, so admins of your system can maintain accounts like normal members. If you don't want this, you can prevent it with business logic when creating accounts.

This approach also allows you to have different types of members -- just associate multiple member profile models with the same user. So, for example, if you need to store additional details about your admin users, you can maintain an AdminUserProfile to keep that data, independent of the MemberUserProfile.

Does that make sense?

Yours,
Russ Magee %-)


On Mon, Feb 3, 2014 at 4:18 AM, Henrique Oliveira <henrique...@gmail.com> wrote:
Hi Timothy,

I see it have officially deprecated the use of user profiles attached to the default user in favor of custom user models.
One thing I have noticed in Django 1.6, only one AUTH_USER_MODEL can be used.

Any ideas how to deal with this?

On Sunday, February 2, 2014 4:26:44 PM UTC-2, Timothy W. Cook wrote:
I suggest, and I believe it is considered best practice by others.  To create a profile model for your members with a one to one relationship to the user.  Basically you do not want anything in the user model that doesn't apply to all users.




On Sun, Feb 2, 2014 at 3:27 PM, Henrique Oliveira <henrique...@gmail.com> wrote:
Hi guys,

I am building a gambling website thas has 2 types of users:

Admin user: An user that manage that manages the website, it is a staff user(As already is done in Django), this user cannot register by yourself.

Member user: It is an user that interact with the website, it has an account, a wallet, can bet, can register itself, this type of user has some custom fields,
such as date of birth, cell phone number.

What is the best way to deal with this requirement using Django?

Cheers

--
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 post to this group, send email to django...@googlegroups.com.



--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

--
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 post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9dacec7c-7b0c-4f1b-a46d-4c3ed5fa65f7%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f4c537d6-b47f-483a-afce-a70e21356bc7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment