Re: view user profile access restriction

2018-01-29 Thread sum abiut
Thanks heaps , I noticed that.

On 29/01/2018 8:28 PM, "Daniel Roseman"  wrote:

On Monday, 29 January 2018 05:57:55 UTC, suabiut wrote:
>
> I manage to fixed it. I have created two instances (profile_info and info)
> in my view, i use the first instance to access the information from my
> Profile model and the second instance to access th User model. I also set
> the *AUTH_PROFILE_MODULE = 'Profile' in my settings.py.*
>
>
The first part is fine, but AUTH_PROFILE_MODEL hasn't done anything since
Django 1.7 - there's no point in setting it.
-- 
DR.

-- 
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/dccb20d9-fe7f-47e5-a1f6-333f2087e4d6%40googlegroups.com

.

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

-- 
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/CAPCf-y5grSsV6pYhvMCmZb%3DRNuGYLo1x%2Ba3AZCp949zvRpEHaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: view user profile access restriction

2018-01-29 Thread Daniel Roseman
On Monday, 29 January 2018 05:57:55 UTC, suabiut wrote:
>
> I manage to fixed it. I have created two instances (profile_info and info) 
> in my view, i use the first instance to access the information from my 
> Profile model and the second instance to access th User model. I also set 
> the *AUTH_PROFILE_MODULE = 'Profile' in my settings.py.*
>
>
The first part is fine, but AUTH_PROFILE_MODEL hasn't done anything since 
Django 1.7 - there's no point in setting it.
-- 
DR.

-- 
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/dccb20d9-fe7f-47e5-a1f6-333f2087e4d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: view user profile access restriction

2018-01-28 Thread sum abiut
I manage to fixed it. I have created two instances (profile_info and info)
in my view, i use the first instance to access the information from my
Profile model and the second instance to access th User model. I also set
the *AUTH_PROFILE_MODULE = 'Profile' in my settings.py.*

*my updated view.py*


def loggin(request):

if request.user.is_authenticated:
profile_info=request.user.profile
info=request.user
return render(request,'dashboard.html',locals())


cheers,



On Mon, Jan 29, 2018 at 3:17 PM, sum abiut  wrote:

> Thanks heaps that worked. But then how to i retrieve the rest of the
> profile info from the second table? i have a one-to-one relationship. i
> mange to extract data from the user table which is first name, last name,
> email. but i am having difficulty figuring out accessing information from
> the second table (Profile)
>
> view.py
>
> ef loggin(request):
> username=None
> if request.user.is_authenticated:
> info=request.user
> return render(request,'dashboard.html',locals())
>
>
>
>
> my model.py
>
> class Profile(models.Model):
> user=models.OneToOneField(User, on_delete=models.CASCADE)
> bio=models.TextField(default='',blank=True)
> sex=(
> ('Male','Male'),
> ('Female','Female'),
>
> )
>
> Gender=models.CharField(max_length=100,choices=sex,blank=
> True,default='')
> Phone=models.CharField(max_length=20,blank=True,default='')
> island=models.CharField(max_length=100,blank=True,default='')
> city=models.CharField(max_length=100,blank=True,default='')
> country=models.CharField(max_length=100,blank=True,default='')
> organization=models.CharField(max_length=100,blank=True,default='')
>
>
> account_number=models.CharField(max_length=100,blank=True,default='')
> bank_phone=models.CharField(max_length=100,blank=True,default='')
>
>
> def create_profile(sender, **kwargs):
> user = kwargs["instance"]
> if kwargs["created"]:
> user_profile = Profile(user=user)
> user_profile.save()
> post_save.connect(create_profile, sender=User)
>
>
>
>
>
>
>
>
>
> On Mon, Jan 29, 2018 at 1:02 PM, Dylan Reinhold 
> wrote:
>
>> There are a bunch of ways to do it.
>> Show us your view, if it's a function based view, just do your select on
>> (username=request.user)
>>
>> Dylan
>>
>> On Sun, Jan 28, 2018 at 4:59 PM, sum abiut  wrote:
>>
>>> Hi,
>>> i have a django app that i want the users to be able to view only their
>>> user profile once they have login. currently any user that login is able to
>>> view other users profile as well. Appreciate is you could point me to the
>>> right direction.
>>>
>>> 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+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/ms
>>> gid/django-users/CAPCf-y7ZZx0BfQe0jwZu8-h%2Bo7nU%3DZYg%3Dgr2
>>> nxYeU%2BjskVTCtw%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> 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/ms
>> gid/django-users/CAHtg44CnQo8DtMunvmR5StuFD3vw5y0dk8dJqXM46m
>> tDuaxR_w%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
>

-- 
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/CAPCf-y5PMBn70mJf72da-NPJPs2Kgf%2B%2BUArMP1orLqdXOYaotQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: view user profile access restriction

2018-01-28 Thread sum abiut
Thanks heaps that worked. But then how to i retrieve the rest of the
profile info from the second table? i have a one-to-one relationship. i
mange to extract data from the user table which is first name, last name,
email. but i am having difficulty figuring out accessing information from
the second table (Profile)

view.py

ef loggin(request):
username=None
if request.user.is_authenticated:
info=request.user
return render(request,'dashboard.html',locals())




my model.py

class Profile(models.Model):
user=models.OneToOneField(User, on_delete=models.CASCADE)
bio=models.TextField(default='',blank=True)
sex=(
('Male','Male'),
('Female','Female'),

)


Gender=models.CharField(max_length=100,choices=sex,blank=True,default='')
Phone=models.CharField(max_length=20,blank=True,default='')
island=models.CharField(max_length=100,blank=True,default='')
city=models.CharField(max_length=100,blank=True,default='')
country=models.CharField(max_length=100,blank=True,default='')
organization=models.CharField(max_length=100,blank=True,default='')


account_number=models.CharField(max_length=100,blank=True,default='')
bank_phone=models.CharField(max_length=100,blank=True,default='')


def create_profile(sender, **kwargs):
user = kwargs["instance"]
if kwargs["created"]:
user_profile = Profile(user=user)
user_profile.save()
post_save.connect(create_profile, sender=User)








On Mon, Jan 29, 2018 at 1:02 PM, Dylan Reinhold  wrote:

> There are a bunch of ways to do it.
> Show us your view, if it's a function based view, just do your select on
> (username=request.user)
>
> Dylan
>
> On Sun, Jan 28, 2018 at 4:59 PM, sum abiut  wrote:
>
>> Hi,
>> i have a django app that i want the users to be able to view only their
>> user profile once they have login. currently any user that login is able to
>> view other users profile as well. Appreciate is you could point me to the
>> right direction.
>>
>> 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+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/ms
>> gid/django-users/CAPCf-y7ZZx0BfQe0jwZu8-h%2Bo7nU%3DZYg%
>> 3Dgr2nxYeU%2BjskVTCtw%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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/CAHtg44CnQo8DtMunvmR5StuFD3vw5
> y0dk8dJqXM46mtDuaxR_w%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAPCf-y6QWOcy%3DH7%3DnBsTzSKFcChQM9uavenia%2BH2PokSd55gog%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: view user profile access restriction

2018-01-28 Thread Dylan Reinhold
There are a bunch of ways to do it.
Show us your view, if it's a function based view, just do your select on
(username=request.user)

Dylan

On Sun, Jan 28, 2018 at 4:59 PM, sum abiut  wrote:

> Hi,
> i have a django app that i want the users to be able to view only their
> user profile once they have login. currently any user that login is able to
> view other users profile as well. Appreciate is you could point me to the
> right direction.
>
> 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+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/CAPCf-y7ZZx0BfQe0jwZu8-h%2Bo7nU%
> 3DZYg%3Dgr2nxYeU%2BjskVTCtw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAHtg44CnQo8DtMunvmR5StuFD3vw5y0dk8dJqXM46mtDuaxR_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.