You can user permission classes in your code. Or decorators before the
function view you want to be only visible to logged in users.

from django.contrib.auth.decorators import login_required


@login_required

def your_view_here(request):



On Mon, 6 Jul 2020 at 01:28, Exactly musty <exactmusty1...@gmail.com> wrote:

> how can i specify a user in django templates, for example i have a page
> which consist of list of users available but i want it to show "Talk to a
> patient" for only the logged in user on his own profile here is what am
> saying in picture and here is my code, i actually don't know how to put the
> code i have tried many code but it does show Talk to a patient for every
> users or it wont show at all,i attached a picture to it,that shows what am
> saying,i checked the doc but couldn't find anything to use,so i wanted to
> try the custom templates tags,but i still don't how to comport the code in
> the templatetags views
>
> *Models.py*
>
>
>
> class Doctor(models.Model):
>     GENDER_CHOICES = (
>         ('Male', 'Male'),
>         ('Female', 'Female'),
>     )
>     user = models.OneToOneField(CustomUser, on_delete=models.CASCADE, null=
> True, related_name="doctor")
>     image = models.ImageField(default='jazeera.jpg', upload_to='
> profile_pics')
>     full_name = models.CharField(max_length=100)
>     bio = models.TextField()
>     speciality = models.CharField(max_length=300)
>     describtion = models.CharField(max_length=100)
>     status = models.ManyToManyField(Status)
>     gender = models.CharField(max_length=6, choices=GENDER_CHOICES)
>     location = models.CharField(max_length=100)
>     certification = models.CharField(max_length=300)
>     place_of_work = models.CharField(max_length=300)
>
>
>
>
>
> *##template*
> {% if request.user == doctor %}
>                     <p><a href="{% url 'chat' %}" class="btn btn-primary
> ">Talk to a Patient</a></p>
>                       {% endif %}
>
>
>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4278d2eb-53a1-4b9c-89fa-a5d09f96c458o%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/4278d2eb-53a1-4b9c-89fa-a5d09f96c458o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGyqUuW1CNsNZDk%3DP%2B%2B8SAkBLa5ty7W6-T4DbzOyF0PNggGcJQ%40mail.gmail.com.

Reply via email to