6

I deployed my django app to pythonanywhere.com and my admin css not working http://directdirect.pythonanywhere.com/admin/login/?next=/admin/ what do I do? I use django 2.0 settings.py:

 Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'django_direct/main_app/static'),
    os.path.join(BASE_DIR, 'django_direct/main_app/static'),
    http://directdirect.pythonanywhere.com/static/admin/css/dashboard.css
]
9
  • 1
    Did you follow the steps indicated by the docs in howto/static-files in deployment Commented Apr 20, 2018 at 20:19
  • Where is your setting STATIC_ROOT pointing to? Can you check your server if the files are where they are supposed to be? Commented Apr 20, 2018 at 20:21
  • @Ralf i did $ python manage.py collectstatic no help Commented Apr 20, 2018 at 20:36
  • Can you show STATIC_ROOT as well, not just STATIC_URL ? Commented Apr 20, 2018 at 20:42
  • How have you configured your webserver to serve static files? Commented Apr 20, 2018 at 20:42

4 Answers 4

7

Check your settings.py file.

DEBUG = True    # debug true mod working admin css
DEBUG = False   # debug false mod not working css

You can fix it using a proxy server or by running Django with the insecure parameter.

Sign up to request clarification or add additional context in comments.

Comments

2

I assume you followed similar instructions to this page from help.pythonanywhere.com.

There it says:

Go visit your site, it should be live! But it probably won't be using your CSS stylesheets, JavaScript and other things that are loaded from static files. To get those set up, check out the page configuring static files with Django.

And here is the link to get those static files up and running.

This should point you in the right direction.

Comments

1

This problem in python anywhere is occuring due to django admin templates deep in the sitepackages folder cannot reach the css files through its url because it is not yet existing here in pythonanywhere.

That's why you need to add:

another URL in the Static files: located inside the Web beside Console, Files, and Databases

put /static/admin/ in the value of URL and for the path, it depends on where your django admin static files are located. The common path is this one (if you're using a virtual envrionment) /home/<username>/.virtualenvs/<virtrualenvname>/lib/python3.6/site-packages/django/contrib/admin/static/admin

Refer example

2 Comments

You need to go higher, everybody is talking about collect static, that creates a bunch of redundant folders, but for me, this is the best solution :-)
Yeah You are Right i need to go higher and i am going :) . Thank you for your time and consideration
-1

Just move the admin folder from static_cdn to static folder

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.