Tuesday, June 21, 2011

Re: Many user profiles

Thank you very much Francesco,

Works like a charm...

On 20 juin, 15:33, francescortiz <francescor...@gmail.com> wrote:
> Try doing this in your models.py:
>
> def get_profile(self):
>     ...your code to get the profile for a the user...
>
> User.get_profile = get_profile
>
> On Jun 20, 9:54 am,gontran<geoffroydecorb...@gmail.com> wrote:
>
> > Hello evreybody,
>
> > I wonder how to deal with many user profiles.
> > I need to store different informations depending on the status of my
> > users.
>
> > I have a generic UserProfile class:
>
> > class UserProfile(models.Model):
> >     user = models.OneToOneField(User, primary_key=True)
> >     role = models.CharField(max_length=1, choices=USER_ROLE)
>
> > and other classes for different profiles:
> > CustomerProfile, EmployeProfile, ...
>
> > For the admin part, I managed to separate each category of users with
> > proxy models.
> > I know that I can override get_profile() on each proxy model based on
> > the User class.
>
> > What I want to do:
> > u = User.objects.get(pk=x)
> > u.get_profile() ---> return the profile associated depending on the
> > status of the user. If u is a customer, return a CustomerProfile
> > instance, if u is an employe, return à EmployeProfile instance and so
> > on.
>
> > Is it possible to do it?
>
> > Thanks in advance for your help.
>
> > Regards,
>
> >Gontran

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate