I think you're looking for a detailView <https://docs.djangoproject.com/en/3.0/ref/class-based-views/generic-display/#generic-display-views> .
You'll likely need to pass <int:project_name> in your URL config to the view in order to filter the boqmodel by the foreignKey. Here's a video explaining detailViews. <https://www.youtube.com/watch?v=TrJtYmfTWiA> Dominick delponte.d...@gmail.com On Mon, Dec 16, 2019 at 4:07 PM Raviteja Reddy <ravi2teja2...@gmail.com> wrote: > I am creating a project management app Each user has multiple projects and > each project has a set of data When first logged in the user sees a list of > all the projects only he created.i am able to do this. Then when clicked on > the project the data related only to that project is to be shown. How do i > do that in django? My projects model > > On Monday, December 16, 2019 at 1:32:45 AM UTC+5:30, Raviteja Reddy wrote: >> >> class projectsmodel(models.Model): >> added_by = >> models.ForeignKey(settings.AUTH_USER_MODEL,null=True,blank=True,on_delete=models.SET_NULL) >> projects=models.CharField(max_length=300) >> >> def save_model(self,request,obj,form,change): >> obj.added_by=request.User >> super().save_model(request,obj,form,change) >> def __str__(self): >> return self.projects >> >> My BOQ Model,it is the model that needs to be filtered based on project >> it is redirected from >> >> class boqmodel(models.Model): >> project_name = models.ForeignKey(projectsmodel, null=True, blank=True, >> on_delete=models.SET_NULL) >> code = models.IntegerField() >> building = models.ForeignKey(building, on_delete=models.SET_NULL, >> null=True) >> level = models.ForeignKey(level, on_delete=models.SET_NULL, null=True) >> activity = models.ForeignKey(activity, on_delete=models.SET_NULL, >> null=True) >> subactivity = models.ForeignKey(sub_activity, on_delete=models.SET_NULL, >> null=True) >> duration = models.IntegerField() >> linkactivity = models.CharField(max_length=300, null=True, blank=True) >> linktype = models.CharField(choices=choicestype, max_length=300, >> null=True, blank=True) >> linkduration = models.IntegerField(default=0) >> plannedstart = models.DateField(null=True, blank=True) >> plannedfinish = models.DateField(null=True, blank=True) >> actualstart = models.DateField(null=True, blank=True) >> actualfinish = models.DateField(null=True, blank=True) >> >> -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/696df99c-0795-44d5-b5d6-c7562e58c11c%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/696df99c-0795-44d5-b5d6-c7562e58c11c%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALLhV5T78NLfx8uTn9MJHf3jvTH7A%3Du%2BP4c-uTvOsf8nhSR1Cg%40mail.gmail.com.