SHARE
TWEET

Untitled

a guest Oct 20th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Model =====
  2. class viewtype(models.Model):
  3.     user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='worktype')
  4.     user_Type = models.CharField(default='student', max_length=30)
  5.  
  6.  
  7. view
  8. =======
  9. def teacher(request):
  10.     data = User.objects.all()
  11.     return render(request, 'teacher.html', {'data': data})
  12.  
  13.  
  14. Templates
  15. ===============
  16. {% for data in data %}
  17.   {{ data.User.worktype.user_Type }}
  18. {% endfor %}
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