Variabledoesnotexist error always

Variabledoesnotexist error always

Postby uroosa » Tue Jul 26, 2016 6:20 am

Hello All,
I've defined this block in my base.html

{% split_pieces nav_cats_short as cols 3 %}
{% for col in cols_short %}
<ul class="col-sm-4 nav-mega-{{ forloop.counter }}">
{% for cat in col %}
<li><a href="{{ cat.get_absolute_url }}">{{ cat|truncate_ends_with }}</a></li>
{% endfor %}
</ul>
{% endfor %}

and defined nav_cats_short in another context.py file as

def nav_cats_short(request):
return {'nav_cats_short': Course.objects.filter(primary_cat=1)}

I've another def in this file as well
def nav_cats(request):
return {'nav_cats': Cat.objects.filter(active=True)}

and page is recognizing it successfully but on nav_cats_short It is raising Variabledoesnotexist every time.Can some one help me what I'm missing ?

Thank you.
uroosa
 
Posts: 3
Joined: Tue Jul 26, 2016 6:07 am

Re: Variabledoesnotexist error always

Postby nilamo » Thu Jul 28, 2016 9:59 pm

Is this Django? Aren't the only variables available to the page, whichever ones you returned from the controller (or view, as they call it)? So if you wanted both, you'd need to return both from whichever method is spawning this page, right?
Code: Select all
def index(request):
    return {
        'nav_cats_short': Course.objects.filter(primary_cat=1),
        'nav_cats': Cat.objects.filter(active=True)
    }
This forum is shutting down. Future discussion should take place at http://python-forum.io
User avatar
nilamo
 
Posts: 87
Joined: Thu Jul 21, 2016 8:00 pm
Location: Michigan


Return to Web Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron