Why can't I access Django Administration Interface without running collectstatic command?

Hi there,

Everything was working fine, and I was pushing the latest code to heroku for deployment. But suddenly I tried to test on my local computer and I was unable to open the Django Administration Interface, it was showing Server Error 500. I searched and found out I need to run the following command:

python manage.py collectstatic

I ran this command and the Django Administration Interface was working fine again. But this command made a lot of files in the staticfiles folder in my project’s main directory where I have manage.py file.

My question is why can’t I run the Admin interface anymore with those bundle of static files. Is there any way for me to again run Admin Interface without those static files? If not, is there anyway to hide those files like move them to some other folder and not keep them in the project’s main directory?

Actually, your staticfiles would ideally be outside your projects directory. (I know heroku does some strange things, but that really shouldn’t prevent a proper deployment from being done.)

Static files should be served by your web server, not by your application. As a result, your static files should be in a directory serviced by your web server, not your application server.

What should I do to restore my project to the point when it was working fine without staticfiles on my local computer?

@KenWhitesell I downloaded the previous version from GitHub which was working absolutely fine, but now Admin interface in that is also not working and showing Sever Error (500). Can you help me because I am like being mad, all of my hard-work is wastage now.

I’m sorry, but I really don’t have any advice to give. I don’t use Heroku, and I don’t know what you need to do to do a proper deployment in that environment. I’m hoping you can find a solution.

Somethings, that might help you in solving this error:

I have following in my settings.py:

DEBUG = False

ALLOWED_HOSTS = []

Is this something that is making it go wrong?

I solved it by changing:

ALLOWED_HOSTS = []

to

ALLOWED_HOSTS = ["*"]