M
M
ma3xak2018-06-10 10:59:59
Django
ma3xak, 2018-06-10 10:59:59

What's wrong with static?

What went wrong with the statics on DJANGO is not returning all static files.
for example

<link rel="stylesheet" href="{% static 'style_lk.css' %}">
    <link rel="stylesheet" href="{% static 'style.css' %}">

The first file does not give, but the second loads.
Settings
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR,  'media')
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) \
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
ma3xak, 2018-06-11
@ma3xak

The problem turned out to be that the documentation was not read, it was decided like this

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

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files
STATIC_URL = '/static/'
STATICFILES_DIRS =(os.path.join(BASE_DIR,'static/',),) 
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "static", "media")
STATIC_ROOT = os.path.join(BASE_DIR, 'static_root')
#Перенаправляем после авторизации 
LOGIN_REDIRECT_URL = '/'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question