Apache don't actualize new css - django

I have a django server which is run by mod_wsgi and apache.
Today when I tried to update the css in one of my html pages, the css file was updated but apache was still showing the old css. I tried to rename the css file but it didn't work out.
What can I do ?
Thank you

It sounds like the pages are being cached. Probably with browser caching. Try and clear your cache and/or open up your dev tools and go to network and disable caching.

Related

Django Admin Styling corrupted

I recently made some changes to my django site, one big one being upgrading from Django 2.2 to 3.1. Now my admin site styling is all messed up. I can't figure out what went wrong or how to fix. Any pointers would be appreciated!
See image of what it looks like after update....
The main home page for admin looks fine, but when I click on one of the models to view, the formatted is definitely not correct.
Also, some not all, of my images on the site are saying 404 not found...
It looks like your browser is caching the CSS / JS from the old version, you can clear your cache and reload. In chrome use ctrl + shift + r to reload.
I was facing the same problem, First I thought it was a Cache issue but it wasn't.
I checked the page source and found a css file being applied to the page which wasn't even present on my drive.
In my case the file was:
static/admin/css/nav_sidebar.css
So I created new file in static/admin/css named nav_sidebar.css,
then copy pasted the code which I got from page source and
added "display:none;" in the #nav-sidebar section(line:34) and [dir="rtl"] #nav-sidebar section(line:45 in my case).
You can find the Original code here by using Google Chrome's inspect tool.
Where to find the code
I had the same issue after bumping django from v3.0 to v3.1. I run python manage.py collectstatic to update css which solved my issue
I was experiencing the same styling as the OP's screenshots.
I had upgraded incrementally from 2.2 -> 3.0 -> 3.1 -> 3.2. I only experienced the styling issues in 3.2
The issue was that there were legacy admin styles committed to the repo in the static folder. To resolve, all I did was delete the committed admin styles, and Django then appeared to use its own styling
I was upgrading from 3.0 to 3.2 and I tried a couple of the answers here without luck. At the end, the following procedure solved it for me:
manually delete the content of the directory STATIC_ROOT (see in settings.py what you named the folder)
run the command python manage.py collectstatic This will repopulate the directory with the newst files
hard refresh your page (ctrl + F5)
I think the other answers here are necessary, but I'll add one more: You might have to bust caches in your server itself. In our example, nginx was configured to provide really long caches to our static files, so we just had to reset it to make changes come through.
Ok maybe I am late to the party but it may help others,
What works for me is:
Set STATIC_ROOT in settings.py (I guess it should be already there as project is old one)
Comment STATIC_DIR in STATICFILES_DIRS list (otherwise it will give error) and run python manage.py collectstatic
Clear browser cache.

Django not serving eot files

I have following structure (inside static directory):
css
--stylesheet.css
--fonts
---flexslider-icon.eot
stylesheet.css opens correctly in browser (like mysite.com/static/css/stylesheet.css)
But eot file is processed by django.
Why?
All js and css files, as well as images open correctly.
Can you try with a different browser? Some browsers will work quirkily with font files.
If trying with other browsers doesn't do the trick,
Are you using the default web server? Have you tried running your site with Gunicorn web server (http://gunicorn.org/)? Its a very simple test to do.

CF10 developer on IIS7.5 / WIN7 - CFM files run ok - but can't see .GIFs

Can anyone help with this strange problem.
I have just installed CF10 developer on Win7 which is using IIS7.5.
Installation went smooth, and can browse .cfm files no problem and connect to datasources no problem .. BUT: even though I can browse all my local cf sites, none of the sites will display images or styles for external .CSS files.
So, I get the site, content from the database, and all the functionality of cfm files being parsed OK, but no styles and no images.
If I browse directly (pasting the filepath in the browser) to one of the images I get a 404 error - file not found - even though the .gif file does indeed exist in the directory.
So, basically, I can run CFM files, and browse a local site built in coldfusion, but none of the images or externally referenced css files will be "found" by the browser/IIS.
Can anyone help?
Thanks in advance if someone can..
Sounds like an issue with those mimetypes, please see the following for information on installing the static content role to IIS and enabling those mimetypes to be served.
No Mime Types Option in IIS 7
Be sure to enable static content in IIS 7.
Had two occurrences of this problem lately.
See here:
http://weblogs.asp.net/anasghanem/archive/2008/05/23/don-t-forget-to-check-quot-static-content-service-quot-in-iis7-installation.aspx
Try restarting the IIS server. Close all browsers and restart.
You need to determine if it is a CF issue or an IIS issue. Try the following:
Check to see if this is an issue with images not being served vs broken paths to the images. There may be CFML code that is creating links to invalid locations.
If the locations are valid then it would be an issue with IIS not server image files.
Also check to see if there is a similar issue with JPEG and PNG files. If JPEGs and PNGs show up, this suggests an IIS issue.
Also try creating a simple HTML page that has an image on it. If it has an image on it, this suggests a CF issue

MemoryError with Django while serving a movie file

In my Django application, I list the contents of a directory which contains movies (of around 400 MB). When I try to play the movie in the browser, I get MemoryError. I have this movie content inside the "media" folder which I have marked to serve as statically.
I believe this movie should have been served directly through my web server without passing the request to Django. Is there some error in my configuration or is there whole together a different solution available for serving movies as in my case.
I am using lighttpd with Django and FCGI.
Thanks.
You are running out of memory because you read the whole file in memory & buffer it before serving it. Remove the static url config from django urls.py and configure that url to be served by lighthttpd.
But the best way for movies of that size are best served is streaming. Take a look at any media streaming server and see if it helps you. This may help you.
Streaming movies by flowplayer and lighthttpd
--Sai
Could it be that you haven't configured lighttpd to handle requests to /media/ itself and Django is running in debug mode (DEBUG = True in your settings.py).
If you follow Django's own docs for lighttpd deployment, this shouldn't happen.
I solved the error myself.
Actually the problem was with a misconfiguration with my lighttpd server. The problem was that I had configured my webserver to redirect every request to Django and allow Django to process the request and server the response through the webserver.
So, what was happening is when I request to play a large movie file (say around 400 MB), this request went to Django and somehow Django was loading the file in the memory.
Since it was an embedded device with a limited memory, Django threw an "MemoryError".
I changed the configuration of my webserver and everything worked like a charm.
Hope this helps someone in the future. Cheers!

Django's admin pages are missing their typical formatting/style, have I set it up wrong?

I finally got my django install working, however I'm noticing that the typical look and feel of the admin pages are missing, and it's as if there are no styles applied to the structure of the pages. Do I have some kind of setup issue or pathing issue that's preventing the style sheets from being found? Where are they stored? My pages look like they are from 1994.
Sounds like your admin media isn't being served correctly. In your settings.py, there's a variable called ADMIN_MEDIA_PREFIX, which specifies the URL where Django should look for them. The actual media files are in "[path to your Python site-packages]/django/contrib/admin/media". When using manage.py runserver, the files are served "automagically". However, when using Apache/nginx/etc it's your responsibility to make sure that your server makes the files available at that URL (using rewrite rules, symlinks, etc). More info can be found here.
I've solved this issue simply with the alias on apache:
Alias /static/admin/ /usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/
Alias admin/media/ /usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/
You need to provide more info for use to help you properly. However, this is most probably because didn't set up your Web server to serve static file, and therefor, the admin CSS is not loaded.
To solve this, got the the admin and look at the HTML source. You'll css the path to the admind css. Make your web server service this file on this path.