Best practice for Django components -
Best practice for Django components -
django provides means of collecting assets widget framework, , in turn using form nowadays it, how doing outside forms framework?
for example, let's want simple, self-enclosed web component requires 2 .js files, css file, template, , backed view generate data. isn't "form" because it's not intended collect input. rather, assume it's, say, customized scrollbar. can't seem find right match usage pattern though seems mutual , straight-forward.
to seems mean adding css top-level template; js template (or script tags arbitrarily in included document); , rendering form include. wouldn't easier have like:
class scrollbar(...): template_name = ... class assets: ...
and rendering via templatetag, ability context processor or other hook extract assets appropriate places in page?
something like:
index.html:
<html> <head> ... {% compressed_css %} </head> <body> ... {% compressed_js %} {% block content %} {% endblock %} </body>
scrollbar-using-page.html
{% extends "index" %} {% block content %} {% scrollbar args %} {% endblock %}
with end result beingness scrollbar's template rendered specified args, , js , css merged compressed_css , compressed_js areas, respectively, above?
i think there 100% via approach, without compressed_js/compressed_css sections, raises question of whether included these in shared pages. (alternatively, utilize nested/inherited blocks.)
adam
django
Comments
Post a Comment