Re: Retrieve current user id in urls.py

2012-11-28 Thread Peter Edström
Thank you. It's quite logical when you know it. :-)


> This isn't something you do in the urlconf. You do that in your view, 
> where the current user is available already as `request.user`.
> --
> DR. 
>

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



Re: Retrieve current user id in urls.py

2012-11-27 Thread Daniel Roseman
On Tuesday, 27 November 2012 15:37:19 UTC, Peter Edström wrote:

> Hello,
>
> I've set up a user profile according to 
> thisand
>  now I'm trying to access the id of the currently logged in user in my 
> urls.py, like this:
>
> # urls.py  
>> from django.contrib.auth.decorators import login_required
>> from django.views.generic import list_detail 
>> from myproj.myapp.models import App1
>>
>
>> app1_info = {
>> 'queryset': App1.objects.filter(employee=)),
>> 'template_name': 'template.html',
>> }
>>
>> urlpatterns = patterns('',
>> (r'^logged_in/$', login_required(list_detail.object_list), app1_info),
>> )
>>
>
> In App1 I have a OneToOneField to my user profile, I want to list 
> everything in App1 filtered on the currently logged in user (employee = 
> current_user).
> Every example I find in the docs uses the request.user.username, but I 
> have no request method here.
>
> Any clues?
>


This isn't something you do in the urlconf. You do that in your view, where 
the current user is available already as `request.user`.
--
DR. 

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



Retrieve current user id in urls.py

2012-11-27 Thread Peter Edström
Hello,

I've set up a user profile according to 
thisand
 now I'm trying to access the id of the currently logged in user in my 
urls.py, like this:

# urls.py  
> from django.contrib.auth.decorators import login_required
> from django.views.generic import list_detail 
> from myproj.myapp.models import App1
>

> app1_info = {
> 'queryset': App1.objects.filter(employee=)),
> 'template_name': 'template.html',
> }
>
> urlpatterns = patterns('',
> (r'^logged_in/$', login_required(list_detail.object_list), app1_info),
> )
>

In App1 I have a OneToOneField to my user profile, I want to list 
everything in App1 filtered on the currently logged in user (employee = 
current_user).
Every example I find in the docs uses the request.user.username, but I have 
no request method here.

Any clues?

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