teacher
model can upload courses , then if the teacher has not a profile the institute(model)
which working at will upload the courses does this is write way i have tried in the course
model?class Course(models.Model):
course_name = models.CharField(max_length=20)
student = models.ManyToMany(Student)
institute_name = models.ForeignKey(Institute,on_delete=models.CASCADE , null=True,blank=True)
teacher_name = models.ForeignKey(Teacher ,on_delete=models.CASCADE,blank=True,null=True)
tags = models.ManyToManyField(Category,on_delete=models.CASCADE)
time = models.DateTimeField(auto_now_add=True)
update = models.DateTimeField(auto_now=True)
Then define:
if user loggedin in user.is_institute
So querying in institute model
else loggedin in user.is_teacher
And then will work on teacher model. Does this structure fine ?
I've heard that generic foreign keys
not working with API
from django.contrib.contenttypes.models import ContentType
note : Teacher ,Institute have different fields name
django:2.2
Thanks
--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/4U0qgySiGAY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/C87E7048-E8A5-4987-BDB6-859F8580FCCC%40fattuba.com.