Re: Django Multiple User Profiles Best Practices

2016-05-05 Thread Sudhanshu Shekhar
Hey,

Thanks for the reply. The book was released in March 2015 and I am sure the
authors would've known about the custom user models. It has some very good
suggestions (For intermediate django devs like me at least), though yeah,
this abstract model inheritance idea did seem a little troubling to me too.

I finally ended up creating a single profile with a `user_type` field
dictating which kind of user this was. And I created a json field to store
all the relevant details of this user.
I think I could get away with it because in my case all of these fields are
primarily for information and I don't need to search/index by them (which
would've been a pain since I couldn't query them).

One of the reasons why I avoided the custom user model was because most
blogs discourage the idea (mainly because of troubles with integrating with
other apps). I will rethink my approach given your suggestion though.

Have you tried the custom user model with multiple one-to-one profiles
approach anywhere till date? How do you handle registration in that case?
Eg: Teacher signup form would be different from student signup form. So
have you over-ridden the registration view and then create the profile
based on other form parameters? I am planning to do this only but would
love to know how others have done this already.

One more thing I realized : Django doesn't have a good registration app
that can handle such multiple profiles, registrations and workflows. Eg:
What if I want students to be able to login directly/after email
verifications but teachers need to fill in their profile and wait for admin
approval before they can proceed.

Seems weird as the requirement would be valid for a lot of websites
nowdays. Or is there a good alternative I am missing out on?

On Tue, May 3, 2016 at 11:47 AM, Peter of the Norse 
wrote:

> On Apr 6, 2016, at 9:41 PM, Sudhanshu Shekhar 
> wrote:
>
> Hi,
>
> I am creating a tutor-student forum using Django. For which I need to have
> two different user profiles, one for students and one for teachers.
> However, I am unsure about the best way to do this. I am currently
> following the below approach:
>
> class UserProfile:
>  user = models.OneToOneField(User, reverse_name="profile")
>  #other common Attributes
>  class Meta(object):
>abstract = true
>
> class TutorProfile():
>  #tutor fields
>  class Meta(object):
>abstract = true
>
> class StudentProfile():
>   #student fields
>   class Meta(object):
>abstract = true
>
> class Profile(TutorProfile, StudentProfile, UserProfile):
>   pass
>
>
> The idea is taken from the Django best practices book. However, I am
> curious if there is any other way with lesser space usage. Any thoughts?
>
> PS: I also asked the same question on stackoverflow :
> http://stackoverflow.com/questions/36404889/django-multiple-user-profiles-with-class-based-views-best-practices
> but didn't get any responses.
>
>
> First of all, I don’t like multiple inheritance.  You are in control of
> all of the parent classes, so it might not blow up in your face, but there
> still night be problems down the line.  Second, I think this might be the
> same as just creating a single class with all of the fields, so there’s no
> reason to create three abstract classes for it to inherit from.
>
> How old is the Django best practices book you are using?  Because starting
> with 1.5, you should be using a custom User model
> <https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#auth-custom-user>
>  instead
> of a constant profile.
>
> What I would do, and I’d love to hear some debate about it, is put most
> (or all, depending on requirements) of the fields from the UserProfile in
> the new custom user model, and have two not-abstract profiles with
> one-to-one fields to the user.  If the things in UserProfile don’t make
> sense for all users, then make three profiles which all point to the custom
> user model.
>
> Peter of the Norse
> rahmc...@radio1190.org 
>
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/JfnvYidq2Us/unsubscribe.
> To unsubscribe from this group and all its topics, 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/D4629C3B-5B67-439B-B6B7-0EA2CC7CDFF5%40Radio1190.org
> <https://groups.google.com/d/msgid/django-users/D4629C3B-5B67-439B-B6B7-0EA2CC7CDFF5%40Radio1190.org?utm_medi

Django get user details while registration for admin approval

2016-04-08 Thread Sudhanshu Shekhar
I am creating a Django app for which I want to be able to approve users 
before letting them login to the site. Am using django-user-accounts from 
pinax for the same. This approval step requires users to submit additional 
information such as their qualifications etc. This information should be 
asked after the registration page and stored with their profile. Even after 
they have confirmed their email, they shouldn't be able to login unless 
admin has approved them.

I am confused between two options :

1) Over-ride registration flow and show the profile edit form (where the 
profile has been created by post_save signal). But the profile-edit view 
should have some kind of authentication too right? how do I ensure it takes 
only the value passed from registration page and nothing else?

2) Login user after registration and show him his profile edit page. This 
page is the shown until he's filled it in after which he sees the waiting 
for admin approval text. This will be achieved with a mixin which will then 
be inherited by all my views. My concern here is the database fetch which 
will occur each time this mixin is run.

This seems like a pretty common flow. What's the best way to achieve this? 
Thanks

-- 
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/298fa580-1cc9-4164-95fe-3f743094ca7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Multiple User Profiles Best Practices

2016-04-06 Thread Sudhanshu Shekhar
Hi,

I am creating a tutor-student forum using Django. For which I need to have 
two different user profiles, one for students and one for teachers. 
However, I am unsure about the best way to do this. I am currently 
following the below approach:

class UserProfile:
 user = models.OneToOneField(User, reverse_name="profile")
 #other common Attributes
 class Meta(object):
   abstract = true

class TutorProfile():
 #tutor fields
 class Meta(object):
   abstract = true

class StudentProfile():
  #student fields
  class Meta(object):
   abstract = true

class Profile(TutorProfile, StudentProfile, UserProfile):
  pass


The idea is taken from the Django best practices book. However, I am 
curious if there is any other way with lesser space usage. Any thoughts?

PS: I also asked the same question on stackoverflow 
: 
http://stackoverflow.com/questions/36404889/django-multiple-user-profiles-with-class-based-views-best-practices
 
but didn't get any responses.

-- 
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/24499b2a-09fb-4dcb-83f4-2684ce9533a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Deploying Django Application to AWS Beanstalk

2015-10-21 Thread Sudhanshu Shekhar
Hi,

I am a Django newbie trying to deploy my own site to the AWS beanstalk 
(free tier) but am facing a lot of issues doing so. The current AWS 
documentation seems incomplete (they don't mention setting up databases 
etc). Can someone please tell me how to deploy a Django application to AWS.

I asked a question on stack overflow but haven't received any answers there 
either 
: 
http://stackoverflow.com/questions/33131324/database-trouble-deploying-django-app-to-amazon-beanstalk

Thank you!

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2b0c14fa-20ba-406b-b795-b4d2e68fc43e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.