numbas / editor

An editor for the Numbas e-learning system.
http://numbas.mathcentre.ac.uk
Apache License 2.0
59 stars 61 forks source link

Settings.py issue with Static Directory #610

Closed vishwa58 closed 10 months ago

vishwa58 commented 3 years ago

I am trying to contribute to the Numbas Repo and this is my first time contributing, and I believe I have found an issue, but please excuse me if this is not true.

I followed the installation start guide (http://numbas.github.io/editor/mac-local.html), to get Numbas installed on my local machine (I use a Mac).

However, when I tried to preview a new question, I would get a 404 error on chrome and safari. I spent some time on this issue, and found that the problem was on line 128 of settings.py

STATIC_URL = '/static/'

STATIC_ROOT = 'static/'

needs to be changed to

STATIC_ROOT = '' STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join('static'), )

Once I made this change, I was able to preview my questions. I stumbled upon this answer from this stack overflow link (https://stackoverflow.com/questions/12809416/django-static-files-404)

I would be more than happy to submit a pull request, but before I did that I wanted to make sure this was a legitimate issue, and not something I inadvertently caused while configuring Numbas on my local machine.

Thank you for your help and please let me know if there is anything more I can do to better format this question or provide more information.

christianp commented 3 years ago

Did you have DEBUG = False in your settings.py file? In that case, the Django development server doesn't serve static files, so you have to do the collectstatic job as described in https://docs.numbas.org.uk/en/latest/server-installation/ubuntu-web.html#ongoing-maintenance.