Hi!
I have a model with a Sections and Categories related this way:

class Category(models.Model):
    categoty = models.CharField(max_length=200)
    name = models.CharField(max_length = 200, help_text=u"Имя категории")

    def __unicode__(self):
        return u"Категория %s" %self.name

class Section(models.Model):
    section = models.CharField(max_length=200, unique=True)
    name = models.CharField(max_length=200, blank = True)
    category = models.ForeignKey(Category, blank=True)

    def __unicode__(self):
        return u"%s" %(self.section)


I passed a categories to the template. Is there a way I can display all
sections related to each category in template?

Not sure how to do it?

{% for category in categories  %}
 <ul>
  <li id="csstip" class="x"><a href="{{ category.category }}">{{
category.name}}</a>
    {% for section in %}
                But how to get all sections from one category?
  </li>

And the second question

If I am passing a variable to the base template (I want to use the code to
generate menu from categories), how to handle it in separate (extended
templates)? E.g. do I have to query categories in each my view and pass it
as value to all templates I use?


Thanks in advance
Oleg

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to