Jump to content

Django CSS files not found


Recommended Posts

Hi, as a new developer I have been having problems deploying my django/python application to johnny.  After several attempts, I cannot seem to be able to get access their CSS and other static files

In my local server work ok, but when i upload to Johnny can't find my bootstrap css files

 
settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'apps.hello',
]
STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static_collected')
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'), '/home/username/public_html/helloserver/static/',)

 

I add an exception for the static directory in my .htaccess

 

.htaccess

RewriteEngine On
RewriteBase /
RewriteRule ^(static/.*)$ - [L]
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(admin_media/.*)$ - [L]
RewriteRule ^(helloserver/dispatch\.wsgi/.*)$ - [L]
RewriteRule ^(.*)$ helloserver/helloserver/dispatch.wsgi/$1 [QSA,PT,L]

Can you help me?

Thanks

 

Edited by unionsi
Link to comment
Share on other sites

Hi Krydos,

thanks for your response

 

I resolve the problem.

I was missing the path of my project

In settings.py add STATIC_URL = '/projectpath/static/' and now woks ok

My confussion was need put de path of my project in the settings.py and not is necessary in the .htaccess

 

Thanks

Edited by unionsi
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...