Tuesday, November 27, 2012

Retrieve current user id in urls.py

Hello,

I've set up a user profile according to this and 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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment