Forums

django-admin-bootstrapped

I can't seem to get the templates/static files working for django-admin-bootstrapped. I tried fiddling with the '/static/admin/' url in the web tab. I tried moving all the static files and templates into the .virtualenvs folder (as I saw on a different post on this forum). I tried copyng the templates into myapp folder, all to no avail.

"moving all the static files and templates into the .virtualenvs folder"

i think that's probably a terrible idea. Don't do that. Can you tell me where you saw that advice? I'll go and correct it.

Getting static files working is usually a matter of

  • installing the correct packages into your virtualenv
  • adding new apps to INSTALLED_APPS in settings.py
  • setting the STATIC_ROOT and STATIC_URL settings correctly
  • and running manage.py collectstatic.

There's a guide here: static files for django on pythonanywhere

I saw that idea in this post. Maybe a suggestion on what correct settings for STATIC_ROOT and STATIC_URL should be? Shoul I set them in settings.py or in the 'Web Tab'?

Ok. I'm up and running.

Here's what I put in settings.py;

PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
PROJECT_DIR = BASE_DIR
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'myproject/static')
STATIC_URL = '/static/'
STATICFILES_DIRS = ('~/myvirtualenvfolder/lib/python2.7/site-packages/django_admin_bootstrapped/static',)

And here's what I put in my Web tab;

/static/admin/  as  /home/username/myproject/static/admin/   
/static/        as  /home/username/myproject/static/

Then I ran 'collectstatic', and reloaded the 'web app'.

Thanks Harry for pointing out exactly what I needed to fiddle with.