Hello Bengoshi

 

Try in this way:

 

# Static files (CSS, JavaScript, Images)

# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'

#STATIC_ROOT = os.path.join(BASE_DIR, "static")

STATICFILES_DIRS = [

    os.path.join(BASE_DIR, "static"),

    'staticfiles/painel/static',

    'app_catalogo/templates/static/'

]

 

Regards,

Murilo Gigliotti

+55 11 95272-8600

 

-----Mensagem original-----
De: [email protected] [mailto:[email protected]] Em 
nome de Kai Kobschätzki
Enviada em: segunda-feira, 3 de fevereiro de 2020 10:44
Para: [email protected]
Assunto: static files

 

Hi,

 

I want to embedding css- and js-files for seperate templates.

 

I have an django-project with project/static/css/base.css. In the base.html

 

<snip>

 

    <!DOCTYPE html>

    <html>

    {% load static %}

 

</snap>

 

and in the base.css

 

<snip>

 

 

header {

  background-color: #F8F8F8;

}

 

</snap>

 

In my settings.py

 

<snip>

 

 

STATICFILES_DIRS = [

    os.path.join(BASE_DIR, "static")

]

 

 

STATIC_URL = '/static/'

</snap>

 

It does what it should do. Changing the base.css-file is displaying. Fine.

 

Now I extend an app with the directories project/app/static/css and

project/app/static/js and in the subdirectory css I put a app.css in it

and for testing I write there

 

<snip>

 

header {

  background-color: #888888;

}

 

</snap>

 

In the html-template I write:

 

<snip>

 

{% extends 'base.html' %}

{% block content %}

{{ form.media }}

{% load crispy_forms_tags %}

{% load static %}

<script src="{% static 'app/js/app.js' %}"></script>

<link rel="stylesheet" type="text/css" href="{% static 'app/css/app.css'

%}">

 

</snap>

 

It doesn't work. :(

 

My understanding was that django work first the general.css (here

base.css) and the app-specific-css-files so in this case the

background-color will be overwritten. Is this correct?

 

Anybody know where are my mistakes?

 

Thanks and Greetings

 

bengoshi

 

 

 

 

-- 

You received this message because you are subscribed to the Google Groups 
"Django users" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].

To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9dbf7d0a-9360-2418-b801-ac13f56b77ad%40gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/018801d5da9b%24ba394880%242eabd980%24%40com.br.
  • static files Kai Kobschätzki
    • RES: static files Murilo A. Gigliotti

Reply via email to