Ok, I got it now
What about the inheritance? Question 2?

On Wed, May 20, 2009 at 9:30 PM, Alex Gaynor <alex.gay...@gmail.com> wrote:

>
>
> 2009/5/20 Oleg Oltar <oltarase...@gmail.com>
>
> 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
>>
>>
>>
>>
> {% for section in category_object.section_set.all %}
>
> {% endfor %}
>
> As documented here:
> http://docs.djangoproject.com/en/dev/topics/db/queries/#many-to-many-relationships
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
> >
>

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

Reply via email to