Re: Multiple Profiles in Django 1.11

2017-04-18 Thread Camilo Torres
Hi,

I think you can use the default authentication system and create 2 
different groups: 'students' and 'teachers', give 'students' group 
permissions to all the parts of the application for students; similarly, 
give the 'teachers' group permissions to all the parts of the teachers 
application; you can do this with the admin. When you create new users, you 
should put them in any of the 2 groups; you can do this with the admin or 
programmatically.
Then, in your application views, remember to check for permissions by using 
the already available mixins or function decorators.
Please, read this part of the documentation:

   - https://docs.djangoproject.com/en/1.11/topics/auth/
   - https://docs.djangoproject.com/en/1.11/topics/auth/default/

Hope this helps.

On Tuesday, April 18, 2017 at 9:14:39 AM UTC-4, Bujj wrote:
>
> Hi guys i am new to django and i need some help here, i have created two 
> apps inside my django project namely students and teachers, how do i create 
> an authentication system for each one of them?  where they can register and 
> login to their backend, which will have a totaly different look from one 
> another
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9268f190-33f6-449b-93ae-95b3504fc7ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Multiple Profiles in Django 1.11

2017-04-18 Thread Bujj
Hi guys i am new to django and i need some help here, i have created two 
apps inside my django project namely students and teachers, how do i create 
an authentication system for each one of them?  where they can register and 
login to their backend, which will have a totaly different look from one 
another

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3e9c485d-3656-4720-927d-108b20b98759%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple Profiles

2007-05-27 Thread Vinay Sajip



On May 14, 10:15 am, Bram - Smartelectronix <[EMAIL PROTECTED]>
wrote:
> In my opinion there's only one easy solution which doesn't create
> ridiculous overhead and that is to be able to add fields to the User
> model without having to hack the actual code of the User model. Does
> anyone agree with this?

That'll probably be possible if and when we have a more generalized
framework for object inheritance - then you could inherit from the
User and add fields in the subclass.

Regards,

Vinay


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Profiles

2007-05-14 Thread Bram - Smartelectronix

Amit Upadhyay wrote:
> On 5/9/07, *Vinay Sajip* <[EMAIL PROTECTED] 
> > wrote:
> 
> One simple problem with Amit's approach, as written, is that you have
> to deal with "fuser" and "duser", which feels a little kludgy (I
> realise he was just demonstrating the concept, but the problem still
> remains that you want to think of all the profile information as just
> part of the user model. Is the intention just to avoid saying
> user.get_profile().xxx? Can't this be done by judiciously overriding
> __getattribute__ in User, to delegate to a profile if one is defined? 
> 
> Agree with you. I was suggesting this solution as a part of multiple 
> type of user scenario, where profile itself would be different. For us, 
> we have endusers, and businesses, and we require different kind of 
> profiles for both of them. .get_profile() does not handle this situation 
> (AFAIK).

My problem with the get_profile or any of the proposed fixes is that it 
generates a lot of extra queries which one would normally not have.

for user in User.objects.all()[0:10]:
print user.username, user.get_profile().birthday

will get you 10 queries extra, no matter how much select_related you 
use. In some cases -but not always- you can do:

for profile in Profile.objects.select_related.all()[0:10]:
print profile.user.username, profile.birthday

but doing the query like this doesn't always work!

In my opinion there's only one easy solution which doesn't create 
ridiculous overhead and that is to be able to add fields to the User 
model without having to hack the actual code of the User model. Does 
anyone agree with this?


  - bram

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Profiles

2007-05-11 Thread Amit Upadhyay
On 5/9/07, Vinay Sajip <[EMAIL PROTECTED]> wrote:
>
> One simple problem with Amit's approach, as written, is that you have
> to deal with "fuser" and "duser", which feels a little kludgy (I
> realise he was just demonstrating the concept, but the problem still
> remains that you want to think of all the profile information as just
> part of the user model. Is the intention just to avoid saying
> user.get_profile().xxx? Can't this be done by judiciously overriding
> __getattribute__ in User, to delegate to a profile if one is defined?


Agree with you. I was suggesting this solution as a part of multiple type of
user scenario, where profile itself would be different. For us, we have
endusers, and businesses, and we require different kind of profiles for both
of them. .get_profile() does not handle this situation (AFAIK).

-- 
Amit Upadhyay
Vakao!
+91-9820-295-512

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Profiles

2007-05-09 Thread Vinay Sajip



On May 9, 7:21 pm, Vinay Sajip <[EMAIL PROTECTED]> wrote:
> It appears not. Just to see if it would work, I tried just adding
> overriding __getattribute__ (which just calls the superclass
> behaviour) and it causes some unexpected behaviour in the unit tests.

False alarm - it was a typo on my part. How about this in
django.contrib.auth.User:

def __getattribute__(self, attrname):
if attrname == '_profile_cache':
return models.Model.__getattribute__(self, attrname)
try:
rv = models.Model.__getattribute__(self, attrname)
except AttributeError, e:
if not settings.AUTH_PROFILE_MODULE:
raise
try:
profile = self.get_profile()
rv = getattr(profile, attrname)
except SiteProfileNotAvailable:
raise e
return rv

This would appear to allow access to profile attributes directly on a
User instance, without the need to explicitly show ".get_profile()".

Regards,

Vinay Sajip


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Profiles

2007-05-09 Thread Vinay Sajip



On May 9, 6:37 pm, Vinay Sajip <[EMAIL PROTECTED]> wrote:
> part of the user model. Is the intention just to avoid saying
> user.get_profile().xxx? Can't this be done by judiciously overriding
> __getattribute__ in User, to delegate to a profile if one is defined?

It appears not. Just to see if it would work, I tried just adding
overriding __getattribute__ (which just calls the superclass
behaviour) and it causes some unexpected behaviour in the unit tests.

Regards,

Vinay


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Profiles

2007-05-09 Thread Vinay Sajip



On May 8, 2:57 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 5/8/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote:
>
> I'm having this issue currently as well-- an app I'm working on is
> heavily based on profiles and relations to it, so most code is
> constantly doing user.get_profile.something.
>
> However, consider that this alternate approach forces apps to be
> coupled within a project.
>
> I don't see a simple solution to this.  :-/

One simple problem with Amit's approach, as written, is that you have
to deal with "fuser" and "duser", which feels a little kludgy (I
realise he was just demonstrating the concept, but the problem still
remains that you want to think of all the profile information as just
part of the user model. Is the intention just to avoid saying
user.get_profile().xxx? Can't this be done by judiciously overriding
__getattribute__ in User, to delegate to a profile if one is defined?

Regards,

Vinay Sajip


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Profiles

2007-05-09 Thread Amit Upadhyay
On 5/8/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
>
> On 5/8/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote:
> > I would recommend you take a look at lost-theories.com source code. One
> anti
> > pattern that django docs seems to recommend is use
> > django.contrib.auth.models.User as your main user model
> ...
> > and user.get_profile().friends.all() sounds wrong.
> > With this you can say fuser.friends.get(). Natural.
>
> Replying to Django-user rather than Django-dev.


For context, please read the approach for extending User models as I
borrowed from lost-theories source code:
http://groups.google.com/group/django-developers/msg/55889eafe381a09b

-- 
Amit Upadhyay
Vakao!
+91-9820-295-512

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Profiles

2007-05-08 Thread Jeremy Dunck

On 5/8/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote:
> I would recommend you take a look at lost-theories.com source code. One anti
> pattern that django docs seems to recommend is use
> django.contrib.auth.models.User as your main user model
...
> and user.get_profile().friends.all() sounds wrong.
> With this you can say fuser.friends.get(). Natural.

Replying to Django-user rather than Django-dev.

I'm having this issue currently as well-- an app I'm working on is
heavily based on profiles and relations to it, so most code is
constantly doing user.get_profile.something.

However, consider that this alternate approach forces apps to be
coupled within a project.

I don't see a simple solution to this.  :-/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Extending django User model to multiple profiles

2007-04-18 Thread checco

Hi,

from here, as you certainly know, you can see how to extend the User
model to fit the particular needs of a given application:
http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model

In my application I have two different kind of users, so I have to
extend it twice: which value should I specify for the parameter
AUTH_PROFILE_MODULE in settings.py?

Thanks and regards
Francesco


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple profiles

2007-02-06 Thread voltron

Thanks mrstone for your reply, but there are some things that are not
too clear, please bear with me :)

I take it that I have to define every profile that I like separately
and reference them all using a ForeingKey to user ?
What do I fill in as the standard profile in AUTH_PROFILE_MODULE?

Thanks!


On Feb 6, 8:58 pm, "mrstone" <[EMAIL PROTECTED]> wrote:
> The current framework only allow for one "profile class" per site.
>
> If you want you can  let this class return different profiles
> depending on the user.
>
> class mysiteprofile(models.Model)
>user = models.ForeignKey(User, unique=True,
> related_name='user_profile')
>...
>...
>
>def get_for_user(self):
>  if self.user is something:
>return profile_one
>  else:
>return profile_two
>
> @login_required
> def myview(request):
> profile = request.user.get_profile().get_for_user()
>
> On Feb 5, 5:01 pm, "voltron" <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > Accoridng to the Django book, one could extend the basic user model by
> > adding a profile class, this class is then set in the settings module
> > thus:
>
> > AUTH_PROFILE_MODULE = "myapp.mysiteprofile"
>
> > How do I set multiple profiles? I would like to have different types
> > of users, diffrentiating via different profiles.
>
> > Thanks


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple profiles

2007-02-06 Thread mrstone

The current framework only allow for one "profile class" per site.

If you want you can  let this class return different profiles
depending on the user.

class mysiteprofile(models.Model)
   user = models.ForeignKey(User, unique=True,
related_name='user_profile')
   ...
   ...

   def get_for_user(self):
 if self.user is something:
   return profile_one
 else:
   return profile_two

@login_required
def myview(request):
profile = request.user.get_profile().get_for_user()

On Feb 5, 5:01 pm, "voltron" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Accoridng to the Django book, one could extend the basic user model by
> adding a profile class, this class is then set in the settings module
> thus:
>
> AUTH_PROFILE_MODULE = "myapp.mysiteprofile"
>
> How do I set multiple profiles? I would like to have different types
> of users, diffrentiating via different profiles.
>
> Thanks


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Multiple profiles

2007-02-05 Thread voltron

Hi,

Accoridng to the Django book, one could extend the basic user model by
adding a profile class, this class is then set in the settings module
thus:

AUTH_PROFILE_MODULE = "myapp.mysiteprofile"


How do I set multiple profiles? I would like to have different types
of users, diffrentiating via different profiles.


Thanks


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---