Re: Using Request Info in Generic Views

2009-06-02 Thread Sieker Adi Jörg

Hi,

you can use this: 
http://docs.djangoproject.com/en/dev/topics/auth/#authentication-data-in-templates
 
  to add the user to the template context.

Then you cold write template tags to actually get the data you need  
using the user template variable. 
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags

adi

On 02.06.2009, at 13:33, Keyton Weissinger wrote:

>
> I know I'm in the minority, but I'm still having some trouble grokking
> the details of generic views. I keep thinking I should be using them
> but keep running into the same issue.
>
> Here's my problem: I am building a mgmt site for schools in which
> schools sign up for a monthly service fee. Most of my models have a
> "school" foreign key which is also part of the user's profile.
>
> So to see, for example, a list of teachers, I do something kind of
> like this (assumes login has already occurred):
>
> def myview(request):
>   current_person = request.user.get_profile()
>   current_school = current_person.school
>   teacher_list = Teacher.objects.filter(school=current_school)
>   etc
>
> Almost everything I have has this school property.
>
> My question is this: How do I leverage generic views in this capacity?
> Is there a way to use the request information (specifically
> request.user.get_profile().school in my case) in my urls.py when
> generating my querysets?
>
> Thank you!
>
> Keyton
> 

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using Request Info in Generic Views

2009-06-02 Thread Keyton Weissinger
http://groups.google.com/group/django-users/browse_thread/thread/bde817d4620fdfec

On Tue, Jun 2, 2009 at 7:33 AM, Keyton Weissinger  wrote:

> I know I'm in the minority, but I'm still having some trouble grokking
> the details of generic views. I keep thinking I should be using them
> but keep running into the same issue.
>
> Here's my problem: I am building a mgmt site for schools in which
> schools sign up for a monthly service fee. Most of my models have a
> "school" foreign key which is also part of the user's profile.
>
> So to see, for example, a list of teachers, I do something kind of
> like this (assumes login has already occurred):
>
> def myview(request):
>   current_person = request.user.get_profile()
>   current_school = current_person.school
>   teacher_list = Teacher.objects.filter(school=current_school)
>   etc
>
> Almost everything I have has this school property.
>
> My question is this: How do I leverage generic views in this capacity?
> Is there a way to use the request information (specifically
> request.user.get_profile().school in my case) in my urls.py when
> generating my querysets?
>
> Thank you!
>
> Keyton

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Using Request Info in Generic Views

2009-06-02 Thread Keyton Weissinger

I know I'm in the minority, but I'm still having some trouble grokking
the details of generic views. I keep thinking I should be using them
but keep running into the same issue.

Here's my problem: I am building a mgmt site for schools in which
schools sign up for a monthly service fee. Most of my models have a
"school" foreign key which is also part of the user's profile.

So to see, for example, a list of teachers, I do something kind of
like this (assumes login has already occurred):

def myview(request):
   current_person = request.user.get_profile()
   current_school = current_person.school
   teacher_list = Teacher.objects.filter(school=current_school)
   etc

Almost everything I have has this school property.

My question is this: How do I leverage generic views in this capacity?
Is there a way to use the request information (specifically
request.user.get_profile().school in my case) in my urls.py when
generating my querysets?

Thank you!

Keyton
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---