https://stackoverflow.com/questions/60596945/how-to-create-post-with-different-user-type-two-foreign-key-for-one-post-model

here you go

On Mon, Mar 9, 2020 at 5:09 PM Ryan Nowakowski <[email protected]> wrote:

>
>
> On March 9, 2020 5:13:40 AM CDT, namo <[email protected]> wrote:
> >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?
>
> When you say profile are you taking about Django's notion of a user
> profile?
>
> >
> >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)
>
> I'd rename institute_name and teacher_name to institute and teacher. That
> way you can do course.teacher.name.
>
> >
> >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 ?
>
> Please post the Institute and Teacher models.
> Also are any if these models related to User?
>
> >
> >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
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/C87E7048-E8A5-4987-BDB6-859F8580FCCC%40fattuba.com
> .
>

-- 
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/CAKJtO%2BuMx%3DKVzy_Le0Nv4Er0%2BdpYr9S0%3DOrKMUDFyrpJnPydtw%40mail.gmail.com.

Reply via email to