higlass-server icon indicating copy to clipboard operation
higlass-server copied to clipboard

Django does not display CSS, JS, or images

Open slowkow opened this issue 6 years ago • 6 comments

I'm trying to follow your steps to get higlass-server running. Could I ask if you have any advice to get this working correctly? I think I'm almost there, but something is missing because the assets like JS and CSS are not loading.

I installed like this:

mkdir -p ~/work/github.com/hms-dbmi
cd ~/work/github.com/hms-dbmi

git clone [email protected]:hms-dbmi/higlass-server.git

cd higlass-server

conda create -n higlass-server python=3

conda install cython numpy

pip install --upgrade -r ./requirements.txt
pip install --upgrade -r ./requirements-secondary.txt

Then I tried running:

COOLER=dixon2012-h1hesc-hindiii-allreps-filtered.1000kb.multires.cool

wget -P data/ https://s3.amazonaws.com/pkerp/public/$COOLER

python manage.py ingest_tileset --filename data/$COOLER --filetype cooler --datatype matrix --uid cooler-demo

python manage.py runserver
Performing system checks...

/medpop/srlab/slowikow/miniconda2/envs/higlass-server/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
System check identified no issues (0 silenced).
March 07, 2018 - 02:09:51
Django version 2.0, using settings 'higlass_server.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

At this point I start a tunnel from my laptop to the server:

ssh -N -L 8000:localhost:8000 server

But now the page does not load correctly in my browser on my laptop. I get this in my console when I visit http://localhost:8000/admin

GET http://localhost:8000/hgs-static/admin/css/responsive.css net::ERR_ABORTED
localhost/:6 GET http://localhost:8000/hgs-static/admin/css/base.css net::ERR_ABORTED
localhost/:7 GET http://localhost:8000/hgs-static/admin/css/dashboard.css net::ERR_ABORTED

I can login to the admin console and see some of the HTML, but it is missing all of the assets like CSS.

select_tileset_to_change___django_site_admin

slowkow avatar Mar 07 '18 02:03 slowkow

OK, on second glance I think the site is working well enough, except for the missing CSS and JS. Perhaps those things are unneeded.

When I visit http://localhost:8000/api/v1/tileset_info/?d=cooler-demo I get:

{
	cooler-demo: {
		min_pos: [
			0,
			0
		],
		max_pos: [
			3095693983,
			3095693983
		],
		max_zoom: 4,
		max_width: 4096000000,
		bins_per_dimension: 256,
		transforms: [
			{
				name: "ICE",
				value: "weight"
			}
		],
		name: "dixon2012-h1hesc-hindiii-allreps-filtered.1000kb.multires.cool",
		coordSystem: "",
		coordSystem2: ""
	}
}

slowkow avatar Mar 07 '18 19:03 slowkow

@slowkow regarding the static assets not being served: python manage.py collectstatic --noinput should do the trick. Unfortunately your other q's are out of my scope of higlass-y knowledge.

scottx611x avatar Mar 07 '18 19:03 scottx611x

When I do python manage.py collectstatic --noinput I get lots of Copying messages:

Copying '/medpop/srlab/slowikow/miniconda2/envs/higlass-server/lib/python3.6/site-packages/django/contrib/admin/static/admin/js/prepopulate.min.js'
Copying '/medpop/srlab/slowikow/miniconda2/envs/higlass-server/lib/python3.6/site-packages/django/contrib/admin/static/admin/js/actions.min.js'
Copying '/medpop/srlab/slowikow/miniconda2/envs/higlass-server/lib/python3.6/site-packages/django/contrib/admin/static/admin/js/inlines.js'
...

Then I run python manage.py runserver and nothing has changed. There is still no CSS or JS.

slowkow avatar Mar 07 '18 19:03 slowkow

To be honest, I have the same issue if I run the server by itself (outside of the Docker container). If you find a way to fix it, I'll gladly merge a PR.

pkerpedjiev avatar Mar 08 '18 21:03 pkerpedjiev

  1. make sure the static folders under each app. Django will search static files in each app.
  2. clear your browser cache.

Chenjinyu avatar May 22 '18 19:05 Chenjinyu

@pkerpedjiev @slowkow The CSS is apparently only loaded when you run in DEBUG mode.

Not sure why this is the case but for local instances it's fine (and I stopped thinking about it until I set up a new instance and get mad again 😄)

Open config.json and set DEBUG: true (or cp config.json.sample config.json)

(Note that you have to run python manage.py collectstatic --noinput first.)

flekschas avatar Jun 27 '18 19:06 flekschas