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
##template
-- 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+unsubscribe@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.

No comments:
Post a Comment