background: url({{ MEDIA_URL }}/bg.jpg);
That does not work, because this Django template function only works in .html!
background: url({{ MEDIA_URL }}/bg.jpg);
That does not work, because this Django template function only works in .html!
Django template function only works in .html!
This is totally wrong. Django templates are independent of the format. It can be easily used on any other format, infact for many other purposes.
how can I embed something in CSS?
You serve your css from a static server like nginx or apache (configured for statics); Django does not even access these files. Only during development, for sheer convenience, you can ask django to serve statics too.
In django templates, you need to load the template and render a context. For convenience, render to response does that, and returns it as a http response. If you need to edit a css, you will need to do the loading and rendering as well. When you do this, it might be easier to embed an inline style within the page than importing from an external css file.
Actualy image in CSS can be relative to the CSS file. So you don't really need to put the MEDIA_URL in a CSS file.