1π
Is it correct to assume that your Installer
model is some sort of profile-like model for your User
model?
If so, and once you have the relation between Install
and Installer
, things are much easier, if for example you defined the relation like:
class Install(models.Model):
installer = models.ForeignKey('Installer', related_name='installs')
as you could simply do in your view:
def install_list(request, template_name='installs/installs_list.html'):
installs = request.user.installer.installs.all()
data = {}
data['object_list'] = install
return render(request, template_name, data)
π€Gerard
Source:stackexchange.com