I'm trying to setup a development version of a Django site (developed by someone else) so that I can make edits and test before putting changes live. I'm getting a HTTP 301 error when I try going into 127.0.0.1:8000.
I've tried other ports to ensure I'm not already using it.
I believe the settings should allow me to run this app, for example I've got:
DEBUG = True
ALLOWED_HOSTS = ['*']
The live site is running from HTTPS so I figure there is something within settings.py which is specifying SSL but I cannot find anything.
Two questions:
Is there any way to emulate HTTPS using runserver?
If not, what should I be looking for which might be forcing HTTPS?
I never managed to get this running using runserver. In the end I set it up on a apache server and it ran fine
Related
I have files of TLS certificate(.crt) and key(.key) How can i add them in settings.py and run localhost with https( it is need to add them as text variables not path to these files)? Thanks in advance!
Django runserver does not implement HTTPS and it was not meant to be used in production anyway. There is a package that works similarly with support for SSL (django-sslserver) but rather than using it I would consider setup of NGINX or Apache similar to what could be used in production.
I am trying to set up a Django website on an Ubuntu server hosted on DigitalOcean.
After following the step-by-step DigitalOcean tutorial here: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
I remain stuck as I cannot seem to access Django's development server launched on 0.0.0:8000 with the browser of my local machine. However, I do have a response using -curl from the server's bash terminal. So it seems it can only be accessed from the server itself. Django does not return any error while launching the development server. It lists successful connections (code 200) every time I access it via -curl, but does not show anything when I try to access it via my external browser, as if it is actually not being acecssed.
What I did:
followed this tutorial step-by-step until the launch of Django's development server,
disabled Ubuntu's firewall and no DO firewall is used
added '*' in ALLOWED_HOSTS in settings.py
Any ideas? Thank you very much!
I'm trying to connect to the server with IP_address_server:8000, but the page load without ever wanting to connect.
In fact, I start a Django project, and I did python3 manage.py runserver 0.0.0.0:8000. In the project settings.py, I've included IP_address_server in ALLOWED_HOSTS (on the server), but I got the same issue.
Could anyone be able to tell me what could be the problem?
First, if you are (really meant to)hosting your django application on cloud, you should not use django's inbuild server, that is manage.py runserver. Check official docs, quoting here:
Now’s a good time to note: don’t use this server in anything resembling a production environment. It’s intended only for use while developing. (We’re in the business of making Web frameworks, not Web servers.)
Now, if I am wrong and your application is indeed hosted on Nginx/apache, check server logs, for Nginx, /var/log/nginx/, for Apache, /var/log/apache2/.
If not, you can follow some of Django deployment guides, eg here or here
I am facing an interesting problem where I'm unable to login to the admin page of my app when I access it through wsgi in apache.
However when I try to access it through the django dev server it works just fine.
I don't get a wrong login warning I just see an get redirected to the same page as if nothing happened. Putting in wrong credentials does prompt that I have put in wrong credentials.
The only difference between dev server and the apache should be the I'm using virtualenv when creating the django dev server.
I've made sure to remove the standard paths from the sys.path and make it identical to when the virtual env is invoked.
I'm not seeing anything in the apache logs either.
Thanks!
We have django 1.1.1 website, that works fine on development server (python manage.py runserver). But when we use nginx + wsgi, ngnix is timed out and return "504 Gateway is time out". error.log is empty.
So, probably it is environment issue but I don't know where to start because it was working fine and now its not and I have no error to point me in the right direction. Restarting nginx doesn`t help.
I'm new enough to this environment, could someone possible give me some idea of how I could find the problem
Thanks,
Derek
You can try setting DEBUG = True in settings.py and see if you can review the errors.
If that doesn't work, set DEBUG back to False try setting up the ADMINS so you receive emails with the error reports.
Those are my only suggestions at the moment. Good luck.
Look at the error logs for the Nginx server. My guess is that it's invoking something through FCGI or WSGI (whatever you had set up), but that it's not responding correctly. More detail should be in those logs.
It turned out to be mistake in the middleware configuration ... fixed it and all back to normal.