Thanks, this worked like awesome..!!!
On Thu, Jul 30, 2015 at 3:06 AM, Alex Heyden <mindsbreath@gmail.com> wrote:
{{user}} is implicitly sent in the request, so it might be worth trying to sort out what specifically went wrong when you say {{user.is_authenticated}} went wrong.Here's a fully functioning example of some things you can do with the user object:{% block header %}<header id="navbar" class="navbar navbar-default navbar-fixed-top" role="navigation"><div class="navbar-header"><a class="navbar-brand" href="#">Home</a></div>{% if user.is_authenticated %}<div class="collapse navbar-collapse"><ul class="nav navbar-nav"><li><a href="#">Projects</a></li><li><a href="#">Reports</a></li>{% if user.is_staff %}<li><a href="#">Usage</a></li>{% endif %}</ul><ul class="nav navbar-nav navbar-right">{% if user.is_superuser %}<li><a href="#">Settings</a></li>{% endif %}<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">{% if user.first_name %}Welcome, {{ user.first_name }}{% else %}Welcome, {{ user.username }}{% endif %}</a><ul class="dropdown-menu navbar-dropdown-menu"><li><a href="#">Sign Out</a></li></ul></li></ul></div>{% endif %}</header>{% endblock %}To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYW0S-UpbAvFY4RuVUQXKKRPsK3DhX1qefSQYvgFk3c3aw%40mail.gmail.com.--On Wed, Jul 29, 2015 at 4:20 PM, sarfaraz ahmed <findsarfaraz@gmail.com> wrote:Hello All,--I am facing an issue in my first django project. I am newbie. So, please help me in detail. I don't want to use {{full_name}} in all the views. I saw few post which says {{user.is_authenticated}} can be used. I tried but it was not working. Passing {'full_name':request.user.username} to each is very hectic. Also, not sure to this in one of my view where i am using password_change. View is mentioned below where i am not able pass full_name.This is mentioned below is my navigation.html<nav class="navbar navbar-default"><div class="container-fluid"><!-- Brand and toggle get grouped for better mobile display --><div class="navbar-header"><button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><!--<a class="navbar-brand" href="/" >Arham Collections</a>--></div><!-- Collect the nav links, forms, and other content for toggling --><div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"><ul class="nav navbar-nav"><li class="active"><a href="/">Home <span class="sr-only">(current)</span></a></li><li><a href="#">Sale <span class="sr-only">(current)</span></a></li><li><a href="#">About Us</a></li></ul><!-- <form class="navbar-form navbar-left" role="search"><div class="form-group"><input type="text" class="form-control" placeholder="Search"></div><button type="submit" class="btn btn-default">Submit</button></form>--><ul class="nav navbar-nav navbar-right">{%if full_name %}<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{full_name}}<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="/useraccount/edit_user">My Account</a></li><li><a href="#">Orders</a></li><li><a href="/useraccount/edit_user">Profile</a></li><li><a href="/useraccount/change-password">Change Password</a></li><li role="separator" class="divider"></li><li><a href="/useraccount/logout">Logout</a></li></ul></li>{% else %}<li><a href="/useraccount/register">Register</a></li><li><a href="/useraccount/login">Login</a></li>{% endif %}</ul></div><!-- /.navbar-collapse --></div><!-- /.container-fluid --></nav>--------------------------------------------------------------------------------------------------------------------------------------------------------@login_requireddef my_change_password_view(request,template_name='useraccount/password_change_form.html'):return password_change(request,template_name)----------------------------------------------------------------------------------------------------------------------------------------------------------Please help.Regards,Sarfaraz Ahmed
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/f8521d79-c2a0-40a9-bd4e-0a90625264fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
Thanks with regards,
Sarfaraz Ahmed
Sarfaraz Ahmed
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/CAEPJdiwWpupSPc6aKTMjVu7Y1ETOu%2Bgg1wU2zokib6EApqg3hg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment