i'm working on a project the scenario : 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 the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f29df149-9181-4e62-9257-57c68eba323e%40googlegroups.com.

Reply via email to