Display Uploaded Files

I have 4 models that are related to my User model. 3 of them are One-To-One relationships and 1 is a Foreign Key relationship. I want to present all fields from the 5 models in a class based detail view. I can successfully access the fields of the user model and the 3 models with One-To-One relationships, but the model with Foreign Key relationship (userprofilefiles) throws "AttributeError: ‘User’ object has no attribute ‘userprofilefiles’.

class ReviewDetail(DetailView):
    template_name = 'review/review_detial.html'

    def get_object(self, queryset=None):
        user = User.objects.get(pk=self.kwargs.get('pk'))
        print(user)
        print(user.userprofile) # One-To-One
        print(user.userprofilequestions) # One-To-One
        print(user.userprofileagreement) # One-To-One
        print(user.userprofilefiles) # Foreign Key

        return user

I have also tried to get the failing model as a separate object, which works but does not get passed to the template.

class ReviewDetail(DetailView):
    template_name = 'review/review_detial.html'

    def get_object(self, queryset=None):
        user = User.objects.get(pk=self.kwargs.get('pk'))
        print(user)
        print(user.userprofile) # One-To-One
        print(user.userprofilequestions) # One-To-One
        print(user.userprofileagreement) # One-To-One

        upload = UserProfileFiles.objects.get(pk=self.kwargs.get('pk'))
        print(upload) # Foreign Key

        return user, upload

Is there any way to get one of these 2 methods working properly?

You don’t show the UserProfileFiles model, so we can’t be sure exactly what the reference would be (see the related_name attribute). Without that, accessing related data through the reverse of the ForeignKey is done using the _set naming scheme. See the Related objects reference.

Thanks Ken. Here it is!

class UserProfileFiles(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    files = models.FileField(upload_to="files/%Y/%m/%d")