1

So I had some trouble with static files when I tried deploying them... Thing is that I manage to server the main static files and everything is working except for the admin. I think maybe something is wrong with my configuration. Here is screenshot of my web: https://i.sstatic.net/rYxTm.png This is my settings.py:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))

TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates') STATIC_DIR = os.path.join(BASE_DIR, 'static') MEDIA_DIR = os.path.join(BASE_DIR, 'media')

SECRET_KEY = 'ie&_vj_d)t5itbpun3%58tlw(3=ptn1^5qj43kgm^&_z^!5('

DEBUG = False

ALLOWED_HOSTS = ['danielcirstea.pythonanywhere.com']

INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rango', 'registration' ]

MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.locale.LocaleMiddleware' ]

ROOT_URLCONF = 'tango_with_django_project.urls'

TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [TEMPLATE_DIR, ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'django.template.context_processors.media' ], }, }, ]

WSGI_APPLICATION = 'tango_with_django_project.wsgi.application'

LANGUAGE_CODE = 'ro'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATICFILES_DIRS = [STATIC_DIR, ] STATIC_URL = '/static/'

MEDIA_ROOT = MEDIA_DIR MEDIA_URL = '/media/'

REGISTRATION_OPEN = True ACCOUNT_ACTIVATION_DAYS = 7 REGISTRATION_AUTO_LOGIN = True LOGIN_REDIRECT_URL = '/rango/' LOGIN_URL = '/accounts/login/'

3
  • did you run collectstatic ? Commented Jan 14, 2018 at 17:36
  • yes I did but same result Commented Jan 14, 2018 at 18:18
  • Open the admin page on a browser and open the console and share the 404 errors. I suspect that your admin page might be trying to get static files from the URL /static/admin/ , but pythonanywhere seems to be serving it from a different path Commented Jan 14, 2018 at 18:29

1 Answer 1

1

First things first -- the SECRET_KEY in your settings file is something you need to keep secret, and this post is publicly-visible, so you should change it now for safety.

Regarding the admin CSS, the first line in your static files setup looks wrong -- I think the "URL" on that line should be /static/admin. If you change that and then reload the website from the "Web" page, the admin CSS should start working.

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

Comments

Your Answer

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