[英]Django: How to customize display based on the logged in user
creating an attendance system where lecturers register and login using their lecturer code and password different lecturers teach different subjects, currently, the "subject" page displays all subjects present in the database创建一个考勤系统,讲师使用他们的讲师代码和密码注册和登录不同的讲师教授不同的科目,目前,“科目”页面显示数据库中存在的所有科目
as such i would like the "subject" page to display only the subjects taught by the specific lecturer因此,我希望“主题”页面仅显示特定讲师教授的主题
how can i achieve that?我怎样才能做到这一点?
(ps. still a beginner in django..a detailed answer or resources will be highly appreciated) (ps. 在 django 仍然是初学者..将非常感谢详细的答案或资源)
Source code https://github.com/Zainab692/Fyp2/tree/master/django-project/cms源代码https://github.com/Zainab692/Fyp2/tree/master/django-project/cms
Instead of subject=Subject.objects.all()
you need to filter it.而不是subject=Subject.objects.all()
你需要过滤它。 Here it filters by if the "name" contains "Foo"如果“名称”包含“Foo”,则在这里进行过滤
subject=Subject.objects.filter(lecturer_name__name__contains="Foo")
You can use this as a GET query parameter like this: Capturing URL parameters in request.GET您可以将其用作 GET 查询参数,如下所示: Capturing URL parameters in request.GET
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.