Advertisement
MeWWEbcw_Roblox

Python

Jan 15th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. from iiColePlayzii Roblox Player- Follow him on ROBLOX for this to work!
  2.  
  3. class Categories(models.Model):
  4. nom = models.CharField(max_length=255)
  5.  
  6. def __unicode__(self):
  7. return self.nom
  8.  
  9.  
  10. class SousCategories(models.Model):
  11. categorie = models.ForeignKey(Categories)
  12. nom = models.CharField(max_length=255)
  13.  
  14. def __unicode__(self):
  15. return self.nom
  16.  
  17. from django.shortcuts import render_to_response
  18.  
  19. from categories.models import Categories, SousCategories
  20. from fiches.models import Fiches
  21.  
  22. def home(request):
  23. cat = Categories.objects.all().order_by('nom')
  24. scat = SousCategories.objects.all()
  25.  
  26. return render_to_response('fiches/index.html', {'cat': cat, 'scat':scat})
  27.  
  28.  
  29. <ul>
  30. {% for c in cat %}
  31. <li>{{ c.nom }}
  32. <ul>
  33. {% for scat in c.souscategories_set.all %}
  34. <li>{{ scat.nom }}</li>
  35. {% endfor %}
  36. </ul>
  37. </li>
  38. {% endfor %}
  39. </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement