Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from iiColePlayzii Roblox Player- Follow him on ROBLOX for this to work!
- class Categories(models.Model):
- nom = models.CharField(max_length=255)
- def __unicode__(self):
- return self.nom
- class SousCategories(models.Model):
- categorie = models.ForeignKey(Categories)
- nom = models.CharField(max_length=255)
- def __unicode__(self):
- return self.nom
- from django.shortcuts import render_to_response
- from categories.models import Categories, SousCategories
- from fiches.models import Fiches
- def home(request):
- cat = Categories.objects.all().order_by('nom')
- scat = SousCategories.objects.all()
- return render_to_response('fiches/index.html', {'cat': cat, 'scat':scat})
- <ul>
- {% for c in cat %}
- <li>{{ c.nom }}
- <ul>
- {% for scat in c.souscategories_set.all %}
- <li>{{ scat.nom }}</li>
- {% endfor %}
- </ul>
- </li>
- {% endfor %}
- </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement