The project is hosted (support say to solve the problem yourself and therefore my friends hope for your help) and you can find it at: https://caparolcenterspb.ru
All styles, pictures and js appear on the main page, but not on other pages. You can see the errors directly in the browser, but just in case I give a screen:
It seems you are adding the path to the static file not from the STATIC_ROOT, but from the current URL. I'll explain with the example.
On the main page, you got the link:
https://caparolcenterspb.ru/
And looking for the static logo at:
https://caparolcenterspb.ru/static/img/Logo.svg
And all works fine. But if you will go to
https://caparolcenterspb.ru/services/
The URL for the logo request will change to:
https://caparolcenterspb.ru/services/static/img/Logo.svg
Which is wrong and there are obviously no files on this link.
So, the solution to your problem will be fixing STATIC_URL in Django settings. You need to use the same fixed STATIC_ROOT for all static requests and everything will be fine.
It is pretty simple, just check everything is done as it described here:
https://docs.djangoproject.com/en/3.0/howto/static-files/
The shown error explains your MIME is text/html not text/css. It's linked to your browser or OS.
Try to add this in your settings.py:
import mimetypes
mimetypes.add_type("text/css", ".css", True)
Related
I have set up a basic Django system and am testing out the admin app. The admin screen displays with raw styles and not the pretty ones shown in the tutorials and specified in the style-sheets.
Following several other questions, I found this is a common problem caused because Django doesn't normally serve static files. However, it does if DEBUG is switched on and I do have debug switched on. I followed all of the suggestions in the answers anyway to collect static files, etc.
If I enter the static file URLs directly they get downloaded and I can see the files in the developer mode of the browser (both Chrome and Edge). So I think the static files are being served.
Furthermore, if I save the page using the browser, it saves all of the static files and then if I open the main page it is shown with the correct styles. So the styles are working.
So it would seem to me that the files are being served and the browser is getting them and it can render them (from a saved file) but it somehow isn't working when served from Django.
Can anyone tell me what is going on?
EDIT:
Here is a strange thing: if, using the Chrome developer tool, I select the base.css file, click somewhere in the text of the CSS (say at the end of a line) and then add a space, suddenly the page appears correctly.
If I then do refresh the page it goes back to unstyled again.
EDIT 2:
I saw a recommendation to install the Whitenoise app to serve static file so I went ahead and did it. I turned off debug and presto! the styles appear. Turning on debug (so I presume django serves the files) and the styles go away. I saved both sites to the file system and compared the directories using a compare tool. There was no difference.
I'm not calling this an answer as the question is:
Why?
Also, I can't have debug on and get styles.
The problem is described in title. I have this template for a blog that I'm creating using Django.
When I open it normally, using double click over the HTML file, it looks like this:
But when I open it via url from the Django project, it looks like this
It only shows a green square (part of the css) but obviously can't open the css correctly.
Any idea to solve this?
In Django you don't open the HTML with double click on the file, you need to run the server first and open your site using the localhost (like you did in the second picture).
Judging by those images, are you sure you put the image in the static folder? In Django, the HTML files stays in the "templates" folder of your app and the css, javascript and images in the "static" folder.
If this answer doesn't help you, then you should post your code here, otherwise I can't find the problem.
I am trying to use ckeditor in a web project I am currently developing.
The problem is that when I try to instantiate the Ckeditor (either via the jQuery adapter or with the CKEDITOR.replace command), the editor is created but it is hidden.
I inspected the source code and for some reason it has this css attribute
.cke_skin_kama {
visibility: hidden;
}
Then I checked the css files that it uses and I noticed that the editor.css file has no css rule in it! It's completely empty, although it points to the correct url.
Do you know why this is happening? Any hint would be more than welcome!
Thanks in advance!
UPDATE: I tried to use Tinymce also, but I have the same problem. The file ui.css is empty too.
I am using python-webapp2 for GAE. Could this have any relation to the problem? Any specific configuration I have to do?
Thanks!
The problem probably lies in the declaration of your static files directories. Try to move ckeditor outside the paths of your existing static files. For example add the following in your app.yaml, and of course place the ckeditor in the respective folder:
- url: /ckeditor
static_dir: static/ckeditor
if you want create chkeditor into your page you can use this code after attaching chkeditor javascript file :
<textarea id='chkeditor2' class='ckeditor' name='editor1'></textarea>
class and name is defined into javascript file and this text area will chkeditor panel. sorry for bad english :) i hope this will helpfull for you :)
Hey,
I've been using Django 1.2.1 for some time now and came across Django Debug Toolbar just the other day. It looks really useful and I'm really eager to try some stuff out.
I installed exactly how the readme said. Step by Step. I put the middleware at the end just in case things get caught up but I'm using quite standard middleware (common, sessions, auth and csrf). However, it won't show up on any of my pages. I've tried moving the middleware but to the same effect.
It seems as if I've installed something wrong. But, when I load up the Admin Section of django, the toolbar springs up. I'm not sure what I'm doing wrong. Can the content of my pages effect the toolbar coming up? It's outputting in the mime text/html...
Anyway, any help is greatly appreciated. Thanks in advance.
Here's my Settings.py: pastebin.com/Hu8TgANt
Debug toolbar requires that there's at least a closing </body> tag in the response HTML.
This tag can be changed by changing settings.DEBUG_TOOLBAR_CONFIG['INSERT_BEFORE']
http://django-debug-toolbar.readthedocs.org/en/latest/configuration.html#toolbar-options
A few tipps without knowing your code:
'debug_toolbar.middleware.DebugToolbarMiddleware' should be your last or second to last middle ware entry (not 100% sure how it works out with the flatpagefallback middleware)
'debug-toolbar' as last in the list of INSTALLED_APPS
Double check if the toolbar's assets are loaded
Make sure all toolbar settings are set. (DEBUG_TOOLBAR_CONFIG, INTERNAL_IPS) etc.
The error should be something in there. I know of other problems related getting the toolbar displayed on flatpages so if you only checked on flatpages I suggest you try it on another module.
I had the same problem here, and eventually arrived at this post... Anyway, in my case what I noticed was that I had a javascript error in one of my js included libraries. And that breaked the js interpretation flow. When I fixed the javascript error, the django toolbar worked.
That explains why it worked in the admin pages, but not in my app pages.
Missing INTERNAL_IPS key in settings.py impacts toolbar visibility. Adding this resolves the issue:
INTERNAL_IPS = ('127.0.0.1',)
In my case, I was using Google Material Design Lite as the frontend framework,
which has the style definition,
*[hidden]{
display:none!important;
}
this style is applied to Debug Toolbar's elements which result in displaying nothing.
a quick workaround was to change the MDL's style definition (only possible on local stylesheets, not with cdn hosted) to
*[hidden]{
display:none;
}
I had a similar issue. The solution was closing a div as a non-empty HTML element.
From this
<body>
...
<div id="map-canvas"/>
...
</body>
to this
<body>
...
<div id="map-canvas"></div>
...
</body>
Hope it helps!
In my case the error was very simple.
I removed the footer and it worked like a charm!
Hope this solves an issue for somebody else.
I am working on a Django project for a company. This project worked very well before today.
Today I found a page can not show images (and their corrsponding links). I checked source code of THAT PAGE, I found there are images and links, I just can not find them on the page.
I checked the auth of the server and I am sure I can write things to the database. In fact, I think it is not database mistake because I can find what I want in the page source code, I just can not find them on the page.
Oh my Gosh, I am going to be crazy...
Has anyone suffered similar problem? What kind of problem could it be?
Please help me! Thank you very much!
PS: I can not provide any source code of the project because some business limit...I am really sorry...
Try exploring the site_media directory. If you're images are being served up as static content it could be related to the permissions of that folder on local disk or based on the settings.
Within your urls you may have something similar to:
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '/path/to/media'}),
OR it may reference the path in the settings file something similar to:
STATIC_DOC_ROOT = '/path/to/media'
If the link looks correct for the image, but the side is not rendering the image even directly your issue will be somewhere in these areas.
For more information check the django docs:
http://docs.djangoproject.com/en/dev/howto/static-files/