Q:

Correct way to use Sekizai addtoblock in a DjangoCMS plugin

I am working on a DjangoCMS plugin, which includes a javascript file for itself.   The plugin's Javascript relies on the same libraries that the rest of the site does.   So, here's the conceptual part of what I have right now:
Basetemplate.html
{% load cms_tags sekizai_tags and_a_bunch_of_other_stuff %}
<html>
...
<head>
{% render_block "css" %}
</head>
<body>
...
{% addtoblock "js" %}[jquery]{% endaddtoblock %}
{% addtoblock "js" %}[google api, data, more cool stuff like jqplot.]{%endaddtoblock%}
{% addtoblock "js" %}[my site's library js.] {%  endaddtoblock %}

{% render_block "js" %}
</body>
</html>

Now in the template loaded for my DjangoCMS custom plugin, 
great_calendar_plugin_template.html
{% load sekizai_tags and_a_couple_other_things %}
{% addtoblock "js" %}[plugin javascript file dependency]{%endaddtoblock %}
{% addtoblock "js" %}[plugin javascript file]{% endaddtoblock %}
....

So no matter what I do the plugin javascript files are placed into the final HTML above JQuery and all the other dependencies, rather than underneath where they belong.   What am I missing here? 
Thanks. 

A:

You can fix this issue by putting the "base" addtoblock calls (jquery, etc) as far at the top of your base template as possible.  The important bit is that it's before you call and {% placeholder %} tags, which on most sites means before your opening <body> tag. 
An example dummy template:
{% load cms_tags sekizai_tags and_a_bunch_of_other_stuff %}

{% addtoblock "js" %}[jquery]{% endaddtoblock %}
{% addtoblock "js" %}[google api, data, more cool stuff like jqplot.]{%endaddtoblock%}
{% addtoblock "js" %}[my site's library js.] {%  endaddtoblock %}

<html>
    <head>
        {% render_block "css" %}
    </head>
    <body>
        {% placeholder "mycontent" %}

        {% render_block "js" %}
    </body>
</html>

