hi,
Ok, It is a good method to get the current user. I am sorry for that.

But i just do maintain a django project, and i do not want to change the
template structure.

And now, I have found a new method to resolve the problem.

through a variable CURRENT_USER defined in settings.py to save the current
user  in a view.
and get the current_user from settings.CURRENT_USER.

thanks for your reply.


And i found a strange appearance.

PART_ONE:
I defined a variable named CURRENT_USER

and import the settings in a view like below:

from gmadmin import settings      ################## the gmadmin is the name
of the topo directory

then assign request.user to settings.CURRENT_USER

PART_TWO:
Get the settings.CURRENT_USER  in a .py file

the code:
import settings
user = settings.CURRENT_USER


But it reported a problem: the settings.CURRENT_USER is None .
and the problem disappeared when i use "import settings" instead of "from
gmadmin import settings" on PART_ONE。


Could you talk about it?

regards,
kejun


On Tue, Aug 9, 2011 at 4:23 PM, Daniel Roseman <dan...@roseman.org.uk>wrote:

>
> On Tuesday, 9 August 2011 02:33:47 UTC+1, oops wrote:
>>
>> 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
>>
>
> No, Tom understood you fine, and his answer was quite clear. Get the user
> from the template context into your tag, and pass it from there into the
> list function.
> --
> 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/-/LwpPt4GXW8sJ.
>
> 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