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 re

17 views
Skip to first unread message

Raviteja Reddy

unread,
Dec 15, 2019, 8:02:45 PM12/15/19
to Django users
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)

Parth Joshi

unread,
Dec 16, 2019, 2:43:52 AM12/16/19
to django...@googlegroups.com
Question is trimmed in the subject line. Can you paste it in description?




Raviteja Reddy

unread,
Dec 16, 2019, 5:07:02 AM12/16/19
to Django users
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

Dominick Del Ponte

unread,
Dec 16, 2019, 5:45:30 AM12/16/19
to django...@googlegroups.com
I think you're looking for a detailView.

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.


--
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...@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.
Reply all
Reply to author
Forward
0 new messages