static files not getting served

41 views
Skip to first unread message

Rahul

unread,
Dec 4, 2021, 10:25:23 AM12/4/21
to Django users
hey guys  am using default database i.e. SQL Lite3 but when i deploy it on heroku my static files are not getting served . Please suggest what should i do??

should i use postgres ???

Please HELP

Kasper Laudrup

unread,
Dec 4, 2021, 11:33:56 AM12/4/21
to django...@googlegroups.com
On 04/12/2021 10.52, Rahul wrote:
> hey guys  am using default database i.e. SQL Lite3 but when i deploy it
> on heroku my static files are not getting served . Please suggest what
> should i do??
>

You should tell us some relevant details, e.g. how you are deploying
your project, any error messages, which instructions you have followed
for deploying etc. so someone actually has a chance of helping you.


> should i use postgres ???
>

Static files and the choice of database are not related so that won't
make a difference.

> Please HELP
>

Please don't SHOUT.

Kind regards,

Kasper Laudrup
OpenPGP_0xE5D9CAC64AAA55EB.asc
OpenPGP_signature

Mr. Aryan Sharma 4-Year B.Tech. Computer Science and Engineering

unread,
Dec 4, 2021, 12:55:45 PM12/4/21
to django...@googlegroups.com
At static files url at urls.py. And make a seperate directory for media root as well.  Of your settings are correct project will get pushed .  Then you ensure you have migrated from the console at heroku website

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3afdbdd1-c481-498e-b659-44bfc2e691c4n%40googlegroups.com.

Rahul

unread,
Dec 5, 2021, 8:18:52 AM12/5/21
to Django users
see brother i am not shouting at all . i am using heroku for deployment and i didnt got any big error just in websites console ''failed to load resource server responded with the status of 404 ''
i had deployed by pushing files to github and then using heroku  . i had also used whitenoise but it didnt worked ,, im using sqllite3 which is provided by django .. 

my website is working fine . just all the images which are shown in picture are not workingproblem.PNG

Lakshyaraj Dash X-D 25

unread,
Dec 5, 2021, 8:41:31 AM12/5/21
to django...@googlegroups.com
Inside settings.py,

Write these two lines of code and your static files will be served

import os

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Kasper Laudrup

unread,
Dec 5, 2021, 8:49:41 AM12/5/21
to django...@googlegroups.com
On 05/12/2021 14.18, Rahul wrote:
> see brother i am not shouting at all .

Writing in ALL CAPITAL LETTERS is considered shouting. Please refrain
from doing that. I am also not your brother. Using language like that
makes it hard to take you serious.

> i am using heroku for deployment
> and i didnt got any big error just in websites console ''failed to load
> resource server responded with the status of 404 ''
> i had deployed by pushing files to github and then using heroku  . i had
> also used whitenoise but it didnt worked ,, im using sqllite3 which is
> provided by django ..
>
> my website is working fine . just all the images which are shown in
> picture are not workingproblem.PNG

That's not really relevant information for anyone to help you.

Have you read and tried to follow this:

https://devcenter.heroku.com/articles/django-assets

?

Kind regards,

Kasper Laudrup
OpenPGP_0xE5D9CAC64AAA55EB.asc
OpenPGP_signature

Jet Ezra

unread,
Dec 5, 2021, 8:52:26 AM12/5/21
to django...@googlegroups.com
To me, you are not going to serve static files but media files, am sure that the image linked above was as a result of uploading it somewhere,
However much you try, heroku does not handle media files, when you upload your image, the next refresh of the running dyno will delete it from your file directory, unless you find a way of saving your images in the db direct which django does not emphasise, you should push your media and static files to AWS S3 bucket, if possible, please serve them using cloudfront, your issue will be solved well.

This also increases your sites speed.



--
jet

Adriano Machado

unread,
Dec 5, 2021, 10:36:11 AM12/5/21
to django...@googlegroups.com
Hi, Heroku and SQLite do t match.

Read this:


SQLite runs in memory, and backs up its data store in files on disk. While this strategy works well for development, Heroku’s Cedar stack has an ephemeral filesystem. You can write to it, and you can read from it, but the contents will be cleared periodically. If you were to use SQLite on Heroku, you would lose your entire database at least once every 24 hours.

Even if Heroku’s disks were persistent running SQLite would still not be a good fit. Since SQLite does not run as a service, each dyno would run a separate running copy. Each of these copies need their own disk backed store. This would mean that each dyno powering your app would have a different set of data since the disks are not synchronized.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages