Hi,

May be you miss understanted my meaning.

I just want to get the current user object in a normal .py file out of
views.

And this file just offer some data according to different user.

Do you have any methods to get the goal?

thank you

regards,
kejun

On Mon, Aug 8, 2011 at 11:49 PM, Tom Evans <tevans...@googlemail.com> wrote:

> On Mon, Aug 8, 2011 at 4:19 PM, Kejun He <printer...@gmail.com> wrote:
> > hi,
> > My goal is to generate some data,
> > For example:
> > I defined a template tag, and it is used to generate a menutree, the item
> of
> > the menutree is a list.
> > The list  comes from another .py file.In this file,I want to get a
> current
> > user object(LIKE:request.user),
> >  so I need to get a request object outside the views.
> > or other method to get the current user object is fine.
> > thanks
> > regards,
> > kejun
>
> Put the current user into the template context, and pull the user out
> of the context supplied to your template tag.
>
> A common way of putting the current user into the template context is
> to use a RequestContext to render the template with, and ensure that
> 'django.contrib.auth.context_processors.auth' is in
> settings.TEMPLATE_CONTEXT_PROCESSORS (it is by default).
>
> Template tags are passed the context by default when render() is
> called on the Node returned by the template tag. If you are avoiding
> most of the messiness by using the @simple_tag decorator, you can pass
> @simple_tag(takes_context=True) to be passed the context. See [1].
>
> Cheers
>
> Tom
>
> [1]
> https://docs.djangoproject.com/en/1.3/howto/custom-template-tags/#shortcut-for-simple-tags
>
> --
> 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.
>
>

-- 
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.

Reply via email to