Forums

virtualenv serving static files

I have an app in a virtualenv setup with Django 1.4.3

I have tried putting my django static files under /var/www and also in my directory. I have tried various settings in my settings.py file. No luck. I cannot get the static files to serve.

dc

Hi dc,

Did you get this working in the mean time? I just visited http://dscapuano.pythonanywhere.com/static/zinnia/css/dashboard_zinnia.css and got the proper response.

Yes, except for my admin pages. Just goes to prove the old saying "read the blog first". The admin stuff is only serving the template and ignoring any css. I am going to work on this today.

Hope the electricity stays on though, we are having a blizzard right now.

dc

Time to head out to the shops and stock up on warming liquor!

Though here at PythonAnywhere we of course don't condone drinking and coding. We're not Facebook.

giggles

The blizzard is over. Could not get to the store, had to rely on an old bottle of cognac.

However, I am confused about the static files business, and something is very odd going on.

  1. If I put /static/ and /home/dscapuano/beancatworks/static in the new web app, what happens to the static settings in my settings.py?
  2. I have tried several variations for static and for templates and I am getting really strange and inconsistent results, for example: a. I am using django-admin-bootstrapped. This uses bootstrap for my admin styling. I had this working, and then when I try to change the static location, I lose it. b. I am using django-articles (started out using Zinnia, but it was a bit buggy). I find the page, but it is pulling the page from the site-package and not from my template directory.

Is there a good document that explains the static files?

BTW - I am using Django 1.4.3 under a virtualenv.

Thanks, dc

OK, after playing with this for a good while, I am now serving static files from my virtualenv. However, I am not serving my templates from my app. To get my templates to display, I had to modify them (including admin base_site.html) inside my ~/.virtualenvs/django143/lib/python2.7/site-packages/...

This works, but I still don't understand why I am not accessing the templates directory in the app directory.

Ah, cognac -- perfect for a winter warmer... though I highly recommend hot buttered rum for Django code.

I just had a look around your website, and it all seems to be working now -- did you find a fix?

My "fix" was a kluge. I went into my virtualenvs site-packages and altered the templates and css there. It seems that this is where Django is finding these items. Django is ignoring both my site and template settings in my settings.py file as well as the setting in the new static app.

This may be because of the virtual environment.

I had a back and forth with Giles about this. I don't need the virtualenv, but I cannot seem to undo it either. It seems that even when I try to deactivate the virtual environment, I am still on Django 1.4.3.

Any suggestions?

This is solved. Thanks for the great support. According to Giles, you guys will have an easier way to deal with different Django version. Looking forward to that.

Dave Capuano Brunswick, Maine, USA

@ dscapuano: Cheers!! I'm glad it's fixed for ya!!

☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺