3

I have installed the grapelli admin theme, I also use various javascript files for my templates.

Everything was running fine and after I finished all the various tests, I decided to try setting DEBUG = False on my settings file.

Immediately after I had 404 issues with grapelli's various files as well as some of my own files.

Why did this happen, I have started suspecting that I must add all of grapelli (installed with pip, and located on Python27) inside my app's templates.

What is the procedure of getting ready for production on a Django app that uses various external modules?

EDIT

Since these has to do with my static files then most probably I should have included my setting for static files

    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    STATIC_ROOT = os.path.join(BASE_DIR, 'static')
    STATIC_URL = "/static/"

    STATICFILES_FINDERS = (
        'django.contrib.staticfiles.finders.FileSystemFinder',
        'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
    )

    TEMPLATE_LOADERS = (
        'django.template.loaders.filesystem.Loader',
        'django.template.loaders.app_directories.Loader',
    #     'django.template.loaders.eggs.Loader',
    )
ealiaj
  • 1,525
  • 1
  • 15
  • 25
  • Check your urls.py. Have you enabled static urls nased on DEBUG setting ? – Rajesh Kaushik Aug 15 '15 at 17:00
  • possible duplicate of [Why does DEBUG=False setting make my django Static Files Access fail?](http://stackoverflow.com/questions/5836674/why-does-debug-false-setting-make-my-django-static-files-access-fail) – knbk Aug 15 '15 at 17:57

2 Answers2

2

I think you need to run

python manage.py collectstatic

and set settings for static files. Post collectstatic run you can actually see grapelli folder in your STATIC ROOT directory. Read the django docs here for more details.

Make sure you have not added

static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

to your urls under condition DEBUG == True.

Rajesh Kaushik
  • 1,471
  • 1
  • 11
  • 16
  • I had not used static urls on my urls.py. But I had not used the `collectstatic` command. After running it all of grapelli's files and other stuff where moved inside a */static* directory located at the same level as my `manage.py`. What I have now is * myServer * myApp * static Yet it still complains about not finding the files, eg `http://127.0.0.1:8000/static/grappelli/jquery/ui/jquery-ui.min.css ` Also please note that until now I had a file named *static* inside *myAPP* that had some templates, and it worked fine. – ealiaj Aug 15 '15 at 17:48
  • Ok it took me a while to understand what was going on. I just had to read all of the documentation on the subject. – ealiaj Aug 15 '15 at 18:00
0

Take a look at ALLOWED_HOSTS option in settings.py. You simply need to specify the allowed hosts for your website like:

ALLOWED_HOSTS=['localhost']

or the simplest, but most insecure option:

ALLOWED_HOSTS=['*']
Nhor
  • 3,860
  • 6
  • 28
  • 41
  • allowed host is to raise SuspiciousOperation not 404. Have a look at this https://docs.djangoproject.com/en/1.8/ref/settings/#allowed-hosts – Rajesh Kaushik Aug 15 '15 at 17:04
  • sorry to ask this, but are you completely sure you are writing the domain which your website runs at? – Nhor Aug 15 '15 at 17:07
  • I had this setting set correctly as I had been told that it might cause me issues. Si I am afraid that in this case this is not it. – ealiaj Aug 15 '15 at 17:23