how to pass request.user in .hbs file in django

48 views
Skip to first unread message

JAI PRAKASH SINGH

unread,
Dec 2, 2014, 8:42:21 AM12/2/14
to django...@googlegroups.com
hello all, 
    
i am very new to django , i have just started to work on django , 

i am using .hbs file in django project
my aim is to use request.user in .hbs file 

i am trying this ...
not working 


***********************************************view.py****************************************
data_dict = {.......
                    'user':reques.user,
                    # not working # but stacin name working like user: "jp"
                   .......}

content_type = 'application/json'
return HttpResponse(json.dumps(data_dict), content_type)


*******************************************.hbs file*****************************


 <div class="ratdefsmall"><span class="strong">{{response.user}}NO RATING</span><br></div>


************************************************************************************



Jerry Dumblauskas

unread,
Dec 2, 2014, 8:48:08 AM12/2/14
to django...@googlegroups.com
missing the t? reques.user to request.user

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3a08e636-78ac-4342-8577-816ac25a29e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

JAI PRAKASH SINGH

unread,
Dec 2, 2014, 11:57:10 PM12/2/14
to django...@googlegroups.com
sir,

   thank you for reply. but actually this mistake was while posting , in  my actual code  request.user is present .
   so please if some more  guidance from your side please share ...

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/rxIIoZ0dGLY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

Collin Anderson

unread,
Dec 4, 2014, 8:41:56 AM12/4/14
to django...@googlegroups.com
Hi,

What happens when you try?

You may need to "serialize" the individual attributes of user, or just return request.user.username.

Django has some tools to help you serialize models.

Collin

JAI PRAKASH SINGH

unread,
Dec 4, 2014, 3:24:27 PM12/4/14
to django...@googlegroups.com
hi

actuall when i pass simple static value it shhows it in .hbs file
(user: = "jai prakash singh") but when i pass request.user it show
none (user:request.user) i think u r right , i should passs in
serialise format. thank you let me try, and i will send u what is the
response

thank you again for answer
>>>> <div class="ratdefsmall"><span class="strong">*{{response.user}}*NO
>>>> RATING</span><br></div>
>>>>
>>>>
>>>>
>>>> ************************************************************************************
>>>>
>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users...@googlegroups.com <javascript:>.
>>>> To post to this group, send email to django...@googlegroups.com
>>>> <javascript:>.
>>>> <https://groups.google.com/d/msgid/django-users/3a08e636-78ac-4342-8577-816ac25a29e9%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Django users" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/django-users/rxIIoZ0dGLY/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> django-users...@googlegroups.com <javascript:>.
>>> To post to this group, send email to django...@googlegroups.com
>>> <javascript:>.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CA%2BG_OOsDz5NJdNXGkHi8Y0gUZ1GwdSb%3DouSVPzdz68AiC27bVg%40mail.gmail.com
>>>
>>> <https://groups.google.com/d/msgid/django-users/CA%2BG_OOsDz5NJdNXGkHi8Y0gUZ1GwdSb%3DouSVPzdz68AiC27bVg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/rxIIoZ0dGLY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e5b3c665-42f3-40df-9d84-f13e211707d2%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages