Creating name based user access to certain pages in the nav-bar
There are a couple of ways you could do that. You could have auth Groups added for a user and then check if the user belongs to that group. For example, in your view, you would add the user to a group like this:
from django.contrib.auth.models import Group
user_group = Group.objects.get_or_create(name='some_group_name')
user_group.user_set.add(user_obj)
Then you can use a custom templatetag to check if the current user belongs to a group:
project_dir/app_name/templatetags/sometag.py
from django import template
register = template.Library()
@register.filter
def has_group(user, group_name):
return user.groups.filter(name=group_name).exists()
Then in your template, you can use this template tag like this:
{% load sometag %}
{% if request.user|has_group:"some_group_name" %}
<a href='#'>Your Link here</a>
{% endif %}
If you don't like the templatetag approach, you could filter the user group in your view as well and use it as a flag to display your items in the template.
If that does not work for you, then you can take a look at Permissions.