Multiple UserProfile

17 views
Skip to first unread message

Ignacio Soto

unread,
Jun 10, 2011, 11:51:48 PM6/10/11
to django...@googlegroups.com
Hi there...

i want to create 2 user profile: cutomer and seller with diferents fields and quantity of fields

but there is a problem with Get_Profile()
i've reading about it and i found some inheritance hacks.. but i doubt it was the good way?

what is the right way to do it?

thanks
--
__

Ignacio Soto Reveco
Staff IngeHost

Shawn Milochik

unread,
Jun 11, 2011, 9:06:19 AM6/11/11
to django...@googlegroups.com
Just make your models for the customer and seller profiles, and attach
them to users with a OneToOne field. You can only specify one to be used
with User.get_profile(), but I've learned from discussions among core
developers that get_profile() is something many consider useless. It's
even been proposed to remove it entirely.

If you're writing code that needs to use fields in your customer and
seller profile models then you're obviously going to have to know which
you're using, so there's no benefit to abstracting the
user.seller_profile.get() to user.get_profile(), and it makes the intent
less obvious.


Shawn Milochik

unread,
Jun 11, 2011, 10:39:34 AM6/11/11
to django...@googlegroups.com
Oops, correction: You'd use user.seller_profile and user.customer_profile if you've set it up as a OneToOneField -- the get() is unnecessary (and won't work).

You'd use get() if you used a ForeignKey with unique = True, but that's silly because a OneToOneField does exactly that but more explicitly.


Ignacio Soto

unread,
Jun 11, 2011, 11:51:50 AM6/11/11
to django...@googlegroups.com

Ok, thannks i will try, and let you know...

Cheers

ignacio Soto Reveco
Staff IngeHost

El 11-06-2011 11:41, "Shawn Milochik" <shawn...@gmail.com> escribió:

Oops, correction: You'd use user.seller_profile and user.customer_profile if you've set it up as a OneToOneField -- the get() is unnecessary (and won't work).

You'd use get() if you used a ForeignKey with unique = True, but that's silly because a OneToOneField does exactly that but more explicitly.




--
You received this message because you are subscribed to the Google Groups "Django users" grou...

To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/0weLEapbyMYJ.


To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group,...

Kenneth Gonsalves

unread,
Jun 11, 2011, 8:35:49 PM6/11/11
to django...@googlegroups.com
On Fri, 2011-06-10 at 23:51 -0400, Ignacio Soto wrote:
> i want to create 2 user profile: cutomer and seller with diferents
> fields
> and quantity of fields

can the same person be both customer and seller?
--
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

Ignacio Soto

unread,
Jun 11, 2011, 9:12:53 PM6/11/11
to django...@googlegroups.com

No, the same person cant be costumer and seller.

ignacio Soto Reveco
Staff IngeHost

El 11-06-2011 21:37, "Kenneth Gonsalves" <law...@thenilgiris.com> escribió:

On Fri, 2011-06-10 at 23:51 -0400, Ignacio Soto wrote:

> i want to create 2 user profile: cutomer an...

can the same person be both customer and seller?
--
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/


--
You received this message because you are subscribed to the Google Groups "Django users" group.

To post to this group, send email to django...@googlegroups.com.

To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more op...

Venkatraman S

unread,
Jun 11, 2011, 10:17:00 PM6/11/11
to django...@googlegroups.com

On Sun, Jun 12, 2011 at 6:42 AM, Ignacio Soto <is...@ingehost.cl> wrote:

No, the same person cant be costumer and seller.

Then why not have a 'type' in your profile which tracks the user type?

-V
http://blizzardzblogs.blogspot.com/

Kenneth Gonsalves

unread,
Jun 11, 2011, 11:37:23 PM6/11/11
to django...@googlegroups.com
On Sat, 2011-06-11 at 21:12 -0400, Ignacio Soto wrote:
> No, the same person cant be costumer and seller.

I have a basic profile with information common to both customer and
seller called Person and separate models called customer and seller with
foreign key to person. Thus one person may have multiple roles.

Ignacio Soto

unread,
Jun 12, 2011, 12:09:08 AM6/12/11
to django...@googlegroups.com

Ok, kenneth i havent seen it that way.

I will use your model.

I really apreciate it

Thanks

ignacio Soto Reveco
Staff IngeHost

El 12-06-2011 0:39, "Kenneth Gonsalves" <law...@thenilgiris.com> escribió:

On Sat, 2011-06-11 at 21:12 -0400, Ignacio Soto wrote:

> No, the same person cant be costumer and se...

I have a basic profile with information common to both customer and
seller called Person and separate models called customer and seller with
foreign key to person. Thus one person may have multiple roles.
--

--
You re...

For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply all
Reply to author
Forward
0 new messages