开发者

django-mptt children selection works on localhost but not on server

开发者 https://www.devze.com 2023-01-09 03:12 出处:网络
I have the same code on localhost and on server (thanks to mercurial), but it works a little bit different. I want to render category and its subcategories in template using this code:

I have the same code on localhost and on server (thanks to mercurial), but it works a little bit different. I want to render category and its subcategories in template using this code:

views.py:

def category(request, category_slug):
    try:
        category = Category.objects.get(slug=category_slug)
    except:
        raise Http404
    subcats = category.get_children()

    return render_to_response('catalogue.html',
            {'category': category,
            'subcats': subcats,
    'header_template':'common/includes/header_%s.html' % flixwood_settings.CURRENT_SITE
            },
            context_instance=RequestContext(request))

template:

<div class='subcats'>
    {% for subcat in subcats %}
    {% ifequal subcat.level 1 %}
    <div class="item">
    <a href="{% url flixwood.views.category category_slug=subcat.slug %}"><img src="{% thumbnail subcat.image 66x66 %}" class="thumb"></a>
    <a href="{% url flixwood.views.category category_slug=subcat.slug %}" class="name">{{ subcat.category }}</a>
                    {{ subcat.short_description|safe }}
    <div class="clear_left">&l开发者_C百科t;/div>
    </div>
    {% cycle '' '' '<div class="clear_left"></div>'|safe %}
    {% endifequal %}
    {% endfor %}
</div>

but however this code works perfectly on localhost (subcategories are rendering right) - it doesn't work on server, and the {{ subcats|length }} returns 0. I compared values from MySQL bases on localhost and on server - they are right and inheritance should work. The funniest thing is that the same query works perfectly in manage.py shell on server.

What the hack is wrong with it?


The problem was solved - it was in .pyc files, which are recreating only after apache is restarted. That's why the right code in .py files didn't work.

0

精彩评论

暂无评论...
验证码 换一张
取 消