daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Mar 18th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class student(models.Model):
  2.    studentNumber = models.AutoField(primary_key=True)
  3.    studentName = models.CharField()
  4.  
  5.  
  6. class hobbies(models.Model):
  7.  
  8.   studentNumber =
  9.   models.ForeignKey(student,on_delete=models.CASCADE,blank=True,null=True)
  10.   hobby = models.CharField()
  11.      
  12. def hobbyList(request):
  13.  
  14.    b = student.objects.all()
  15.    c = hobbies.objects.(filter=studentNumber=n) ## here is the problem the n
  16.  
  17.    return render(request,'student/hobby.html',{'b':b,'c':c})
  18.      
  19. <ul>
  20.  {% for n in b %}
  21.  <li>{{ n.studentNumber }}
  22.    <ul>
  23.     {% for s in c %}
  24.      <li>{{ s.hobby }}</li>
  25.     {% endfor %}
  26.    </ul>
  27.  </li>
  28.   {% endfor %}
  29. </ul>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top