Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django does not display CSS, JS, or images #70

Open
slowkow opened this issue Mar 7, 2018 · 6 comments
Open

Django does not display CSS, JS, or images #70

slowkow opened this issue Mar 7, 2018 · 6 comments

Comments

@slowkow
Copy link

slowkow commented Mar 7, 2018

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 git@github.com: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
Copy link
Author

slowkow commented Mar 7, 2018

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: ""
	}
}

@scottx611x
Copy link
Contributor

scottx611x commented Mar 7, 2018

@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.

@slowkow
Copy link
Author

slowkow commented Mar 7, 2018

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 slowkow changed the title server trouble django does not display CSS, JS, or images Mar 8, 2018
@slowkow slowkow changed the title django does not display CSS, JS, or images Django does not display CSS, JS, or images Mar 8, 2018
@pkerpedjiev
Copy link
Member

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.

@Chenjinyu
Copy link

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

@flekschas
Copy link
Member

flekschas commented Jun 27, 2018

@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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants