On Mon, Sep 30, 2013 at 6:11 AM, Rafael E. Ferrero
<
rafael....@gmail.com> wrote:
> I Dont know your design, usually i include the js library on base template
> and my apps templates extend from that... or just put another base template
> for every app...
>
> If you have some example code or tell us why you do that then we be more
> helpfull
My setup looks like this:
Django 1.5
Project/app structure:
mysite/ # Project root
mysite/
settings.py # INSTALLED_APPS includes 'foo', a reusable app
templates/
base.html # Project base template, includes jQuery &
# Bootstrap JS for project
static/ # Static assets for project
js/
jquery.js
bootstrap.min.js
foo/ # Reusable app
templates/
foo/
index.html # app template, extends 'base.html'. Requires
# and includes jQuery and Bootstrap JS for app
static/ # Static assets for 'foo' app
foo/
js/
jquery.js
bootstrap.min.js
app.js
So when 'index.html' from the foo app is rendered, the JS imports look
like this:
<script type="text/javascript" src="/static/js/jquery.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
<script src="/static/foo/js/jquery.js"></script>
<script src="/static/foo/js/app.js"></script>
<script src="/static/foo/js/bootstrap.min.js"></script>
</div> <!-- end container -->
</body>
</html>
...because both the project and the reusable app are using jQuery and
Bootstrap JS, loading them twice on the same page results in screwed
up JS behavior.
Also,
Seems interesting, I'll look into it more. To be honest, I think I'm
looking for a best practice rather than a solution; how are others
managing redundant JS includes when combining their own projects and
reusable apps? I imagine there's no app required to do this
intelligently.
DS
>
https://groups.google.com/d/msgid/django-users/CAJJc_8XTE884Y9oCCK1StrtRGxt0Jvd%3DcJiOfboNOdarK%3DC05A%40mail.gmail.com.
Darren Spruell
phatb...@gmail.com