简体   繁体   中英

CSS not being rendered in Django page?

I set a Django view+url that points to a HTML form. The HTML file is linked to two stylesheets using @import. When I visit the page, terminal tells me that GET requests are sent to the two CSS files, but the page is rendered as pure HTML without any CSS.

Here's the code that links to the stylesheet in the HTML file:

<head>
<title>Register</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style>
    @import url("./css/common.css");
    @import url("./css/desktop.css");
</style>
</head>

Here's the relevant code snippet from the view:

return render_to_response("signup.html", {'form': form,}, RequestContext(request))

Will post more code if asked for it. This is really bugging me. Thanks in advance!

You could try putting the entire css file contents in between the style tags and see if that works. Then you know that it has a problem importing the css files and your path is wrong. Just a suggestion

can you please defined where is your current file location in which you import css because you trying this

<style>
    @import url("./css/common.css");
    @import url("./css/desktop.css");
</style>

in this case your css in is upward then your html page ???? let me know ???

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM