Hi Sunday,
No - you don't. What collectstatic does is it collects all of the static files to the path where they should be stored. This should be a directory that should be served from nginx or apache or any other webserver. When you run manage.py runserver - you run a development server that isn't geared for production. And that is what is serving the files when "DEBUG" is set to True.
To make it work like you want it to:
1. Install a webserver that can serve the static files.
1. Install a webserver that can serve the static files.
2. Install gunicorn, uwsgi or some other wsgi server to serve the django application.
When you have that working you will be able to look at your custom error pages and so on.
There are many good tutorials on howto set this up - I usually look at digitalocean - check here for example:
You can also look at the official django docs for explaining how to run production loads:
When you get this working - serving the static files from a webserver isn't that hard.
Regards,
Andréas
Den mån 1 juni 2020 kl 16:18 skrev Sunday Iyanu Ajayi <sunnexajayi@gmail.com>:
Hi Kasper,Thanks for the response.I serve my static file by running python manage.py collectstatic on the built file I get from the frontend angular guy--On Mon, Jun 1, 2020 at 2:55 PM Kasper Laudrup <laudrup@stacktrace.dk> wrote:Hi Sunday,
On 01/06/2020 15.48, Sunday Iyanu Ajayi wrote:
>
> Please What am I doing wrong? Or are there better ways of serving
> angular build files on django?
>
You haven't described how you are currently serving static files with
Django. I suggest you start by reading this:
https://docs.djangoproject.com/en/3.0/howto/static-files/deployment/
You definitely shouldn't use DEBUG in production and you definitely
should serve static files with your web server of choice.
Kind regards,
Kasper Laudrup
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/12912d74-160c-547a-5cb5-0275432e751d%40stacktrace.dk.
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKYSAw3vLNZ5RDLav-WuUO1kH4rn%3DF%3DcDLFdteK%2BM_4d9rR9HA%40mail.gmail.com.
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCcqMsfK_5Gwd9GkBHTTgR5EQKr9Vmp%3DUaZqt8WuRVCRqQ%40mail.gmail.com.
No comments:
Post a Comment