Running python3 manage.py runserver but not seeing any requests - python

I activated my virtual environment with source env/bin/activate, and then started my server with python3 manage.py runserver 0.0.0.0:80.
I have made sure I have the following in my settings.py:
ALLOWED_HOSTS = ['xx.xx.xx.xxx', 'mywebsite.org']
I start the server and it outputs :
System check identified no issues (0 silenced).
January 28, 2019 - 21:40:33
Django version 2.0.7, using settings 'app.settings'
Starting development server at http://0.0.0.0:80/
Quit the server with CONTROL-C.
But, I visit "mywebsite.org" and it outputs
> Index of /
> Name Last modified Size Description cgi-bin
> 2018-08-23 07:26 -
The homepage of my website normally appears when I visit "http://127.0.0.1:8000/", so how can I get that to appear?
I'm using a Mac

Related

Server stops at http://127.0.0.1:8000/admin/ in python django

Here I am creating my first Django application that is basically a polls app. I have followed these steps:
Created a django app in pycharm.
Wrote two tables in models.py.
Done "python manage.py makemigrations".
It successfully created my migrations.
Done "python manage.py createsuperuser", set its username and
password.
Now doing, "python manage.py runserver", Its opening great.
Issue:
When hitting "http://127.0.0.1:8000/admin/", server just stops. No error and nothing happens. I don't understand that why I am not being able to hit the url.
urls.py
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]
Server state while quitting:
C:\Users\Maha Waqar\PycharmProjects\DjangoSites>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
March 09, 2020 - 21:40:44
Django version 3.0.4, using settings 'DjangoSites.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[09/Mar/2020 21:41:20] "GET / HTTP/1.1" 200 16351
C:\Users\Maha Waqar\PycharmProjects\DjangoSites>
My folder hirearchy:
DjangoSites //root folder
->DjangoSites
->mysite //current app I am working in
It's a bug and can be fixed by upgrade to python 3.8.
https://code.djangoproject.com/ticket/31092

Access development server - Django

I tried to run a friend's Django project on my Ubuntu Virtual Machine but I can't access the development server.
After a:
python manage.py runserver 0:80 --settings=a.settings.dev_a
Here the result :
Performing system checks...
System check identified no issues (0 silenced).
June 19, 2017 - 21:56:31
Django version 1.11, using settings 'a.settings.dev_a'
Starting Channels development server at http://0:80/
Channel layer default (asgi_redis.core.RedisChannelLayer)
Quit the server with CONTROL-C.
Add 'localhost' to ALLOWED_HOSTS in your "dev_a" file
and then like said #FlipperPA, try a
python manage.py runserver [::]:8000 --settings=a.settings.dev_a

Docker refusing connection

I'm trying to run my first ever docker. On console everything seems to be fine, but the chrome says connection is refused. It tried to turn off windows firewall - no effect. Running on win10home.
$ docker run -p 8000:8000 -v `pwd`:/data --rm -it mydjango mynewproject/manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
December 28, 2016 - 11:48:20
Django version 1.10.4, using settings 'mynewproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Dockerfile:
From python:3
RUN pip install django
EXPOSE 8000
RUN mkdir /data
WORKDIR /data
I had this issue when running the server with the command
python manage.py runserver 8080
Running the command
python manage.py runserver 0.0.0.0:8080
Fixed it for me. Note the 0.0.0.0
Could you please try adding "docker ip" in the ALLOWED HOSTS in the mynewproject/settings.py
The url you are checking with is "docker-ip":8000 right?
To get docker docker container IP,
You can use docker inspect
Some thing like this:
CID=$(docker run -d -p 4321 base nc -lk 4321);
docker inspect $CID
Run the following command in CMD for Windows OS by going to the directory of your project then execute these commands:
python manage.py migrate #run this command to sync your Database with Django project
python manage.py runserver # run the server on http://127.0.0.1:8000/
For the more tutorial watch this channel simple Tutorials of Django is available
https://www.youtube.com/playlist?list=PL6gx4Cwl9DGBlmzzFcLgDhKTTfNLfX1IK
I have also learned from here. If you find your answer a Thumbs up will be appreciated . Happy Coding

How can I debug Openstack Dashboard?

I'm running the Openstack Cloud System. I installed and deployed the kilo version on the server successful, but this is only the default version of Openstack. So that, I want to have some modifies on this openstack source and add more features to it.
I started to change something with the Openstack Dashboard. However, there are some problems happened. Therefore, I have debugged this django web application. All everything I have configured is the same as the official tutorials on the openstack website (http://docs.openstack.org).
So, I have search on my server and find out 2 places that have the sources:
The first one is /usr/share/openstack-dashboard/
The second one is /usr/lib/python2.7/dist-packages/horizon/
And the config file is /etc/openstack-dashboard/local_settings.py
I set the option Debug = True in local_settings.py file.
On the server I typed these commands:
cd /usr/share/openstack-dashboard/
python manage.py runserver
Here is the output:
RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
WARNING:py.warnings:RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
WARNING:py.warnings:RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
Performing system checks...
System check identified no issues (0 silenced).
August 05, 2015 - 09:28:50
Django version 1.7.6, using settings 'openstack_dashboard.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
But in the browser, it shows the error:
And then, on the console, it shows:
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[05/Aug/2015 10:21:29] "GET / HTTP/1.1" 302 0
Not Found: /horizon/auth/login/
[05/Aug/2015 10:21:29] "GET /horizon/auth/login/?next=/ HTTP/1.1" 404 4237
Not Found: /favicon.ico
[05/Aug/2015 10:21:29] "GET /favicon.ico HTTP/1.1" 404 4206
Please help me to get out of this problems. And how can to debug Openstack Django Website properly.Thank you very much !
As you run server by runserver command you should go to the root url like
127.0.0.1:8000/
not
127.0.0.1:8000/horizon
The difference is in running method.
When you installed openstack_dashboard there is apache config that listen to address http://host/horizon look in to /etc/apache2/conf/sites-available/
The directories
/usr/lib/python2.7/dist-packages/horizon/
Is like the framework for all dashboards
/usr/share/openstack-dashboard/
Is the default dashboard for openstack
/etc/openstack-dashboard/local_settings.py
The config file for dashboard. Here you can apply changes for default dash, for example attach your project that modifies or extends default dash
So, your problem will be solved if you follow that link http://127.0.0.1:8000/
For debugging use
pdb or ide with integrated debugger
Follow this link.
http://docs.openstack.org/developer/horizon/quickstart.html
Once this is done, add pdb statements to your code that you wish to debug.Go into the horizon folder and run the following command
./run_tests.sh --runserver 127.0.0.1:port_number
Instead of local host you can put in the IP address where horizon is running
I have written the OpenStack documentation for debugging dashboards using PyCharm.
(It is good for any Openstack Dashboard including Horizon)
http://docs.openstack.org/developer/mistral/developer/troubleshooting.html

Running Django with gunicorn: Bad Request (400)

I am following this tutorial to set up a Django application and serve it with Gunicorn on a Debian DigitalOcean server: http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
I have got as far as the section starting "Now that you have gunicorn, you can test whether it can serve your Django application by running the following command". Now I'm stuck.
In other words, I can successfully run the application using python manage.py runserver, but not by using gunicorn.
I've successfully accessed my app with:
$ python manage.py runserver xx.xx.xx.xx:8000
Now from the same directory, I'm trying to run:
$ gunicorn my_django.wsgi:application --bind xx.xx.xx.xx:8001
It appears to start OK, but when I go to http://xx.xx.xx.xx:8001, I see:
Bad Request (400)
I'm not sure how to debug this: there's nothing in /var/log/gunicorn/.
I have set ALLOWED_HOSTS=['xx.xx.xx.xx'] in my settings file.
UPDATE: Being an idiot: gunicorn was looking in production settings file, not local settings file. Setting the ALLOWED_HOSTS in production settings fixed it.
I'd still really like to know how to debug problems like this though.
The answer: gunicorn was looking in production settings file, not local settings file. Setting the ALLOWED_HOSTS in production settings fixed it.

Categories