Django won't start on apache webserver - django

I'm trying to run my django project with an apache webserver.
I get the following error:
Errors : The included urlconf hastahane.urls doesn't have any patterns in it`
If I'm running my project with the django development server there isn't any error.
Do you have an idea?

You should check that the DEBUG settings is set to False and that you have properly filled the ALLOWED_HOSTS list (see the docs).
Also, are you using the django-debug-toolbar? In that case that may be the cause of the error. Check this answer.

Related

gunicorn Serve Error(500) in django 3.2 app on localhost

I'm trying to serve my Django 3.2 application using gunicorn on my localhost. First time, it ran correctly. Later, I changed DEBUG parameter to False in settings.py and I run it again. This time it gives me a server error. In terminal there is no error. See the pictures below. Why is this happening ? How to fix this ?
Error Page
settings.py
terminal
As you are trying to use it in your localhost you need to change the DEBUG = True instead of DEBUG = False and It will work smoothly

Internal server error running Django on Heroku accessing from browser

I think this is a simple fix, but I've deployed quite a few Django apps to Heroku and I still can't figure out what's going on.
Accessing https://dundjeon-finder.herokuapp.com/ gives me a 500 error when using the browser/curl, but if I shell into the app using heroku run ./manage.py shell I can render the views no problem. My logs aren't telling me anything (just that the response is 500) despite DEBUG being set to True, and Sentry isn't receiving an error (it has previously when the database env variable was set badly), so I'm assuming it's something to do with the way the request works.
The repo is public, any help would be much appreciated! The settings file is here.
Well it was because of using asgi instead of wsgi. I'm not sure why that caused the errors, but will do some more searching.

Seeing Django debug 404 page despite having DEBUG = False

I have been following this tutorial along to deploy my first Django site and have successfully reached the section 'Configure Nginx to Proxy Pass to Gunicorn' which all seems to be working.
My problem is that, despite my settings.py file containing the following:
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
I am still getting Django's debug=true 404 page with the following error:
"You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page."
I changed the file to DEBUG = False after completing the 'Configure Nginx to Proxy Pass to Gunicorn' step in the tutorial by pulling the change from my GitHub repository. Am I missing an additional step with Nginx in order to turn debug off and serve a standard 404 page?
Edit: It actually seems that any adjustments I make to the settings.py file in my repository, when pulled on to the server, don't have any effect. I commented out the whole settings.py file to see if it would break the webpage; nothing happened.
I'm guess that you does't restart web server after code editing. Try to restart your Gunicorn server, when you work with django runserver command it automatically restart web server on any change in code. Gunicorn dont do this by default, if you wanted that Gunicorn also restart server automatically, run it with --reload argument. But it dose not recommended into production

In production Page not Found Error when trying to access Django /admin on deployed Heroku app

Friends -
I have a django app (build with cookiecutter) and I have it deployed on Heroku, following these steps here:
https://cookiecutter-django.readthedocs.io/en/latest/deployment-on-heroku.html
Everything works fine and I can also create instances in the database. Now, when I try to enter the admin-page with /admin I get an 404 Page not found error.
When deploying I had this error: (which I ignored)
remote: Invalid input of type: 'CacheKey'. Convert to a byte, string or number first.
remote: --> Continuing using default collectstatic.
I ignored this error because I everything was working. Now, could that be connected or am I just missing something here?
I assume I after deployment I should be able to login to the django admin section, or am I mistaken? I set my admin url in my .env file, but still, I get this problem. Locally everything runs perfectly....
Any help or hints are very much appreciated!

Heroku Server 500 error on particular page

Just deployed a Django app on Heroku. Everything works except for one page of my site which creates a Server 500 error (even though it works fine on my local development server).
The page raising the error doesn't do anything unusual. It makes some database calls, renders some forms, implements JQuery, etc. Any clue what this could be or how I can debug it?
Also, I thought this might be a data issue since my data in Dev doesn't match my data in production, but I checked and this doesn't seem to be the cause.
enable DEBUG=TRUE in your django settings.py file or type in console heroku logs --app your_app to get heroku server logs.
This was because I didn't include a runtime.txt telling Heroku to use Python 3 instead of 2 which subsequently raised an error in one of my views where I called super() with no args.